Records can be retrieved as a DataSet
by invoking the ExecuteDataSet
method of the Database
; also LoadDataSet
can be used to load the data to an existing DataSet
.
The following code block shows record retrieval using ExecuteDataSet:
//Step 1: Create Default Database instance Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>(); //Step 2: Create Database Command - SQL String DbCommand dbCommand = db.GetSqlStringCommand("SELECT CustomerID, FirstName, LastName FROM Customers"); //Step 3: Execute Query DataSet categoryDataSet = db.ExecuteDataSet(dbCommand);
The given code block demonstrates retrieving a DataSet
from the Customers
table using a simple SQL query and executing against the configured database.
3.145.51.153