| Nucleus Login | Lost password? | Close |
|---|---|---|
| Username (email): | ||
| Password: | ||
|
|
||
|
|
||
ASP: Getting data via Access
Problem
How can I use ASP to access a Microsoft Access database and retrieve the wanted information?
Article ID: #KB00039
Number of views: 1269x
Created: 19 May 2008
Latest change: 19 May 2008
Number of views: 1269x
Created: 19 May 2008
Latest change: 19 May 2008
Solution
To make a connection to a Microsoft Access database, you can use the following code:<% strProvider = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= D:/webserver/localuser/username/mdb/mdbmydb.mdb;" Set rst = Server.CreateObject("ADODB.recordset") %>
Afterwards, you can use rst to retrieve the data as follows:
<% strQuery = "SELECT * FROM Tabel" rst.Open strQuery, strProvider %>
This data can be processed in the following manner:
<% If rst.EOF Then Response.Write "No data in database." Else While not rst.EOF For i = 1 To rst.Fields.Count - 1 Response.Write rst(i) Next rst.MoveNext Wend End If %>
