Read data from OleDbConnection ( : OleDbConnection « Database « ASP.Net

Read data from OleDbConnection (

<%@ 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

    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>"

    con_close.text="Connection closed.<br>"
  divListEmployees.innerHTML = strResultsHolder
  catch e as Exception
    con_open.text="Connection failed to open successfully.<br>"
  end try
end Sub

  <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>


Related examples in the same category

1.Working with Transactions with OleDbConnection (
2.Try to connect to access database through OleDbConnection (
3.Reading data from the OleDbConnection in C#