Use DataTable to read the result set from an OleDbDataAdapter and a DataSet (VB.net) : OleDbDataAdapter « ADO.net Database « ASP.NET Tutorial






<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
   sub Page_Load(Sender as object, e as eventargs)
      dim objConn as new OleDbConnection( _
            "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
            & "DATA SOURCE=" _
            & Server.MapPath("EmployeeDatabase.mdb;"))

      dim objCmd as new OleDbDataAdapter("select * from employee", objConn)

      dim ds as DataSet = new DataSet()
      objCmd.Fill(ds, "employee")
      
      dim dTable as DataTable = ds.Tables("employee")
      Dim CurrRows() as DataRow = dTable.Select(Nothing,Nothing, DataViewRowState.CurrentRows)
      Dim I, J as integer
      Dim strOutput as string

      For I = 0 to CurrRows.Length - 1
         For J = 0 to dTable.Columns.Count - 1
            strOutput = strOutput & dTable.Columns(J). _
               ColumnName & " = " & CurrRows(I)(J).ToString & _
               "<br>"
         next
      next

      Response.write(strOutput)
   end sub   
</script>

<html><body>

</body></html>








18.14.OleDbDataAdapter
18.14.1.Fill the DataSet by using the OleDbDataAdapter and connection to Access Database (VB.net)
18.14.2.Use DataTable to read the result set from an OleDbDataAdapter and a DataSet (VB.net)
18.14.3.Filling Multiple DataTables