ASP.NET Web Forms
Adding a SqlDataSource
The first step in using the data from the database in
a web page is to add an SqlDataSource component to the web page
and give it a descriptive name such as CustomersDataSource.
Switch into design view and select the context menu on
the top right hand corner of the component and select
Configure Data Source
Configuring DataSource
The dropdown list should contain the name of your database
(TalkIsCheap.accdb) which can then be selected. If you
expand the Connecxtion string you can see what is going
to be added to your web.config file in order to connect
to that database. Click Next. If the database does not
appear in the DropDown list then create a new database
connection
Connection String
If this is the first time you have connected to the database
you will be prompted to save the connection in a connection
string which could be named TalkIsCheapCoonectionString for
example. The advantage of this is that next time you can
select that connection string in the first dropdown list.
The Select Query
In the next page of the wizard select "Specify columns from a table
or view" and then the required table. By default all the fields
will be selected. However if only a few fields are required, the
fields can individualy be selected.
That is all that is needed if the web page is simply displaying
data. If however you need to update, insert or delete data
click the advanced tab and select generate INSERT, UPDATE and
DELETE. This will generate the SQL needed to complete these
operations. Optimistic Queries is not required as the database
will not be used by multiple users simultaneously.
On the next stage of the wizard you can test the query to
check it works before saving it by clicking Finish.