This topic describes the steps required to create a dataset using the OleDbDataAdapter class.
For the purposes of all the examples found throughout the documentation, we will be using the various tables of the Access version of the Northwind database provided by Microsoft.
To create a dataset using the OleDbDataAdapter class, the following steps must be performed:
Select the OleDbDataAdapter control from the "Data" tab of your toolbox. This should launch the "Data Adapter Configuration Wizard" dialog.
Click on the "Next" button.
Click on the "New Connection..." button. This should launch the "Data Link Properties" dialog.
In the "Data Link Properties" dialog, select the "Provider" tab and choose the "Microsoft Jet 4.0 OLE DB Provider" option. Once this is done, in the same tab, click on the "Next" button. This should bring you to the "Connection" tab of the same dialog.
In the "Connection" tab, select your Northwind Access database ("Northwind.mdb").
Click on the "Test Connection" button to make sure that the connection was successfully established, and then click on the "Ok" button to exit the "Data Link Properties" dialog. You should then be back in the "Data Adapter Configuration Wizard" dialog.
In the "Data Adapter Configuration Wizard" dialog, click on the "Next" button.
In the "Choose a Query Type" page, you should have no other option other than "Use SQL statements". Click on the "Next" button.
In the "Generate the SQL statements" page, click on the "Query Builder" button. This should launch the "Query Builder" dialog with the "Add Table" dialog over it.
In the "Add Table" dialog, select the "Orders" table and click on the "Add" button and then the "Close" button to close the "Add Table" dialog.
In the "Query Builder" dialog, select the "*(All Columns)" option in the "Orders" table. Once you are back in the "Data Adapter Configuration Wizard" dialog, click on the "Next" button.
In the "View Wizard Results" page, click on the "Finish" button to close the "Data Adapter Configuration Wizard" dialog.
You are know ready to generate the dataset that will be used by the Xceed Grid Control:
In the component tray, select the newly created OleDbDataAdapter component. By default, it should be named "oleDbDataAdapter1".
Right click on the OleDbDataAdapter component and select the "Generate Dataset..." option. This should launch the "Generate Dataset" dialog.
In the "Generate Dataset" dialog, by default, the "New" radio button should be selected and the dataset named "DataSet1". For the purpose of these examples, leave the dataset's name to "DataSet1". Leave all other options as they are and click on the "OK" button to create the dataset.
In order for the grid to be populated with data, the dataset must be filled. This is done by calling the Fill method of the OleDbDataAdapter object in, for example, a form's Load event:
C# | Copy Code |
---|---|
oleDbDataAdapter1.Fill( dataSet11 ); |
You can also create a data set manually, using the following code:
C# | Copy Code |
---|---|
|
You are now ready to start using the Xceed Grid Control!