Sample Code : Query an Access database with ASP using a DSN-less connection

<%

Dim cnnSimple  ' ADO connection
Dim rstSimple  ' ADO recordset
Set cnnSimple = Server.CreateObject("ADODB.Connection")

' DSNLess
cnnSimple.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\domains\yourdomain.com\db\yourdb.mdb")

Set rstSimple = cnnSimple.Execute("SELECT * FROM tbltest")

%>
<P> Connecting to Access with Ole connection </P>

<table border="1">
<%
Do While Not rstSimple.EOF
 %>
 <tr>
  <td><%= rstSimple.Fields(0).Value %></td>
  <td><%= rstSimple.Fields(1).Value %></td>
 </tr>
 <%
 rstSimple.MoveNext
Loop
%>
</table>
<%

rstSimple.Close
Set rstSimple = Nothing
cnnSimple.Close
Set cnnSimple = Nothing
%>

 

Was this answer helpful?

 Print this Article

Also Read

Which version of Microsoft .NET Framework do you support?

We support all versions of Microsoft .NET Framework including v1.1, v2 and v3.5 side-by-side on...

How to configure your website for using Ajax (for Windows 2008 Hosting Plans)

Note:  If you want to use ASP.Net "Integrated PipeLine" version (under any circumstance) you...

Can I run multiple ASP.NET Frameworks on different directories on my website?

No. Multiple versions of the ASP.NET Framework cannot run on a single website. The selected .NET...

I get an error 'Server.CreateObject Failed' when I try to use CDONTs. What can I do?

  CDONTs is no longer supported on Windows 2003 server.  Microsoft introduced CDO back...

I get a database timeout expired error on my ASP.NET application. What can I do?

I get the following error when my ASP.NET application connects to the MS SQL server:...