Getting data using the AseDataAdapter object

The AseDataAdapter allows you to view the entire result set by using the Fill method to fill a DataSet with the results from a query by binding the DataSet to the display grid.

Using the AseDataAdapter, you can pass any string (SQL statement or stored procedure) that returns a result set. When you use the AseDataAdapter, by default all the rows are fetched in one operation. If you want the Provider to use cursors, set the property 'use cursor = true' in your connect string. In that case, a forward-only, read-only cursor is used and after all the rows have been read, the cursor is automatically closed by the Provider. The AseDataAdapter allows you to make changes to the DataSet. When your changes are complete, you must reconnect to the database to apply the changes.

You can use the AseDataAdapter object to retrieve a result set that is based on a join.

For more information about the AseDataAdapter, see “AseDataAdapter class”.

AseDataAdapter example

The following example shows how to fill a DataSet using the AseDataAdapter.

StepsRetrieving data using the AseDataAdapter object

  1. Connect to the database.

  2. Create a new DataSet. In this case, the DataSet is called “Results.”

    For C#:

    DataSet ds =new DataSet ();
    

    For Visual Basic .NET:

    Dim ds As New DataSet()
    
  3. Create a new AseDataAdapter object to execute a SQL statement and fill the DataSet called “Results”:

    For C#:

    AseDataAdapter da=new AseDataAdapter(         txtSQLStatement.Text, _conn); 
    da.Fill(ds, "Results"),
    

    For Visual Basic .NET:

    Dim da As New AseDataAdapter( _
       txtSQLStatement.Text, conn)
    da.Fill(ds, "Results")
    
  4. Bind the DataSet to the grid on the window:

    For C#:

    dgResults.DataSource = ds.Tables["Results"],
    

    For Visual Basic .NET:

    dgResults.DataSource = ds.Tables("Results")