Q. How to create a Data Table that has all the unique values for
a column in a database
Generate a new data adapter
- In the toolbox, from the Data tab add a
new Data Adapter. When the Data Adapter configuration wizard appears, click
Next.
- Select the connection to your database that you are
working with and click Next.
- Select Use SQL Statements and click Next.
- Enter the following SQL statement: SELECT DISTINCT
myColumn FROM myTable
- Click the Advanced Options button on the dialog
- Clear the options for Generate Insert, Update and
Delete statements. These statements are not needed for a dataset used for the
population of unique items.
- Click Finish to generate the Data Adapter
Next Generate a new Dataset
- On the new data adapter property box, select Generate
Data Set
- Click on New and enter the name for your dataset such
as dsMyData
- Make sure that you select the Add This Dataset to
the Designer option and click OK. Now the dataset will generated.
|