Quick Objects Documentation Akal Tech Logo
Running a SELECT Statement and Adding Results to an Existing DataSet

Glossary Item Box

Database Library - Tutorial 2:

This tutorial takes the task from Tutorial 1 of the DB Library and displays another feature that allows you to add the results of the SQL command to a DataSet that was created earlier.

DataSet dataSetToFill = new DataSet();

using (DatabaseObjectSQL dbObj = new DatabaseObjectSQL())

{

// This example demonstrate the ability to add the result set table into an existing DataSet.

// RunSQLReturnDataset method has multiple overloads. The following overload takes three values

// and Fills the passed in DataSet with data returned from the SQL statement execution, and the new table name

// is named with the value passed in the third parameter.

dbObj.RunSQLReturnDataset("SELECT FirstName FROM CUSTOMERS", dataSetToFill, "MyCustomers");

if (dataSetToFill != null && dataSetToFill.Tables.Contains("MyCustomers"))

{

this.GridView.DataSource = ds;

this.GridView.DataMember = ds.Tables["MyCustomers"];

}

}