How to query an Access Database with OleDB in ASP.net

<%@ import namespace="system.data.oleDb" %> 
 
<Script runat="server"
 
Sub page_load 
 
 Dim dbconn as oledbConnection 
 Dim dbCMD as oleDbCommand 
 Dim dtr as oledbdatareader 
 
 ' Server.MapPath("[relative path to your database]") 
 dbConn = New oledbConnection ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" & server.MapPath("/test.mdb")) 
 dbConn.open() 
 dbCMD = new oleDbCommand ("select * from tblContact",dbconn) 
 dtr = dbCMD.executereader() 
  
 While dtr.read() 
  response.write ("<li>") 
  response.write (dtr(0) & "---" & dtr(1)) 
 End while 
 
 dtr.close() 
 dbConn.close() 
 
End Sub 
 
</Script> 
 

If you run in to problems using this code, please post in our community forum. Technical support cannot assist with specific coding related issues.