Using the AccessDataSource Control in VS 2005 - Querying the database
(Page 2 of 4 )
Against the database you can run a SQL statement (or a stored procedure), or specify the columns you need displayed by making the appropriate choice. Here a decision has been made to specify the columns, and from the drop-down the appropriate table (Employees) has been chosen with a couple of columns. The SQL statement for the chosen columns appears in the Select Statement: area. You can do more advanced filtering and ordering of your data using the buttons shown on the right. You may also return unique rows of data if you choose to do so. On the other hand you can go to the previous screen and make changes if you like.

When you click on the Next button you will be given a chance to test the query and display its output in the text area as shown.

The field (column) "Photo" was chosen in the select statement, and when the Test Query button was clicked, an error message was shown as in the next picture. It shows the message that you should not choose Memo, OLE Object, or hyperlinks for displaying in the above window.

Click OK to this screen, hit the previous button and drop the column "Photo" by unchecking it. Proceeding forward will display the text only result.

Now click the Finish button, which completes the configuration of the data source for the AccessDataSource control. The configuration parameters that you have chosen and the defaults can be see when you right click to display the properties, as shown in the next picture.

Next: Binding the query result to a GridView >>
More Database Code Articles
More By Jayaram Krishnaswamy