Read data from OleDbConnection (VB.net) : OleDbConnection « ADO.net Database « ASP.Net

ASP.Net
1. ADO.net Database
2. Asp Control
3. Collections
4. Components
5. Data Binding
6. Development
7. HTML Control
8. Mobile Control
9. Page
10. Request
11. Response
12. Server
13. Session Cookie
14. User Control and Master Page
15. Validation by Control
16. Validation by Function
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
ASP.Net » ADO.net Database » OleDbConnection 
Read data from OleDbConnection (VB.net)

<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Oledb" %>

<script language="vb" runat="server">
Sub Page_Load()
  Dim strConnection as String = "Provider=Microsoft.Jet.OLEDB.4.0;"
    strConnection += "Data Source=Northwind.mdb"
    data_src.text = strConnection
  Dim strSQL as string = "SELECT FirstName, LastName FROM Employees"
  Dim strResultsHolder as string

  Dim objConnection as New OledbConnection(strConnection)
  Dim objCommand as New OledbCommand(strSQL, objConnection)
  Dim objDataReader as OledbDataReader

  try
    objConnection.Open()
    con_open.text="Connection opened successfully.<br />"
  objDataReader = objCommand.ExecuteREader()

  Do While objDataReader.Read()=True
    strResultsHolder +=objDataREader("FirstName")
    strResultsHolder +="&nbsp;"
    strResultsHolder +=objDataREader("LastName")
    strResultsHolder +="<br>"
  Loop

  objDataReader.Close()
    objConnection.Close()
    con_close.text="Connection closed.<br>"
  divListEmployees.innerHTML = strResultsHolder
  catch e as Exception
    con_open.text="Connection failed to open successfully.<br>"
    con_close.text=e.ToString()
  end try
end Sub
</script>

<html>
  <body>
  <h4>Reading data from the connection 
  <asp:label id="data_src" runat="server"/> with the DataReader object.</h4>
  <asp:label id="con_open" runat="server"/><br>
  <div id="divListEmployees" runat="server">list will go here</div>
  <asp:label id="con_close" runat="server"/><br>
  </body>
</html>

           
       
Related examples in the same category
1. Working with Transactions with OleDbConnection (VB.net)
2. Try to connect to access database through OleDbConnection (VB.net)
3. Reading data from the OleDbConnection in C#
w___w_w.__j___a_v___a___2__s._c___o___m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.