Use OleDbDataAdapter to fill DataSet : DataSet « ADO.net Database « ASP.NET Tutorial






<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

    void Page_Load(object sender, EventArgs e)
    {
       string ConnectionString = Convert.ToString(ConfigurationSettings.AppSettings["AccessConnectString"]);
       string CommandText = "SELECT * FROM Publisher";
    
       OleDbConnection myConnection = new OleDbConnection(ConnectionString);
       OleDbCommand myCommand = new OleDbCommand(CommandText, myConnection);
    
       OleDbDataAdapter myAdapter = new OleDbDataAdapter();
    
       myAdapter.SelectCommand = myCommand;
    
       DataSet myDataSet = new DataSet();
    
       try {
          myConnection.Open();
    
          myAdapter.Fill(myDataSet);
    
       } catch (Exception ex) {
          throw (ex);
       } finally {
          myConnection.Close();
       }
       myGrid.DataSource = myDataSet;
       myGrid.DataBind();
    
    }

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:DataGrid id="myGrid" runat="server"></asp:DataGrid>
    </form>
</body>
</html>

File: 

<configuration>
    <appSettings>
      <add key="AccessConnectString"
           value="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Books.mdb;" />
    </appSettings>
</configuration>








18.27.DataSet
18.27.1.The DataSet object represents an in-memory database.
18.27.2.Fill a DataSet
18.27.3.Iterating Through A DataSet
18.27.4.Fill DataSet with SqlDataAdapter
18.27.5.Use OleDbDataAdapter to fill DataSet
18.27.6.Iterating Through A DataSet from MySQL database
18.27.7.List Binding To A DataSet
18.27.8.Pulling Single Values From Dataset Bounded Lists
18.27.9.Create DataSet by your own
18.27.10.Serialization capabilities of DataSet