How to access the north wind database?
To retrieve data from data base in ASP, perform the following steps:
open a connection to a database.
2. create a record set, which provides access
to the data fields of each record.
3. retrieve data from the fields of the
4. close the recordset and the connection.
following example shows these basic actions and how they are performed to retrieve
data from the northwide database. The script retrieves al product names and their
prices from the products table, in order by product names, and writes them to
PRODUCT DATA FROM THE NORTHWIDE DATABASE
1: <% @language = VBScript
3: option explicit
4: response. Expires = 0
objconn, objrs, strquery
6: dim strconnection
7: set objconn = server. Createobject
8: strconnection = DSN= northwind; database=
9: strconnection = strconnection & UID=sa; PWD=;
objconn. Open strconnection
11: strquery = SELECT PRODUCTNAME, unitprice
Strquery = strquery & ORDER BY productname
set objrs = objconn. Execute (strquery)
17: all products stored in the product table,
18: orered by
product name: <BR><BR>
20: while not objrs.eof
response. Write objrs (productname) &(
Write fromatcurrency(objrs(unitprice)) & )<BR>
26: objrs. Close
27: objconn. Close
set objrs = nothing
29: set objconn = nothing
lines 1-3, the script instructs the script engine to use VBScript as the default
language and to make sure that every variable is declared.
4 ensures that the browser does not cache the page. Without this line, the browser
would cache the page and the client would see obsolete data if the database, content
has changed between page calls. Recommended
to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.
: We never rent, trade, or sell my email lists to
We assure that your privacy is respected
.NET Programming Tutorial Homepage