Simple ASP for Querying an Access Database
An oldie, but a goodie. (I know, I know: .NET. I need to go to .NET)
'declare variables
Dim sConnString, connection, sSQL, rs
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("MyDB.mdb")
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Open the connection to the database
connection.Open(sConnString)
sSQL = "SELECT * FROM MyTable"
'Implicitly create a recordset object with the
'results of this query
set rs = connection.Execute(sSQL)
Do WHile Not rs.EOF
response.write rs("DB_Field_Name")
rs.MoveNext 'Move to the next record
Loop
' Done. Close the connection object
connection.Close
Set connection = Nothing
0 Comments:
Posta un commento
<< Home