How to connect to MS Access Database Using ASP

How to connect to MS Access Database Using ASP
This tutorial documents code for connecting to a MS Access Database using the DSN-Less approach. With DNS-Less approach all you have to do in your code is define the location where your database resides.


This tutorial will show you how to connect to a MS Access database using the DSN-less approach.
Remember, your database can reside anywhere in your computer. If you are not sharing your database it is advisable not to keep your database under the “wwwroot” directory.


Database is password protected

Running IIS

Just copy and paste the following code in your ASP file and read the comments to modify settings according to your needs: (Text in grey are comments)


‘Start the ASP Tag

Set conn = server.createobject(“adodb.connection”)

‘Define the location of your database and your Password

conn.connectionstring = “DRIVER={Microsoft Access Driver (*.mdb)};


‘Open Connection


Set rs=Server.CreateObject(“ADODB.recordset”)

‘Enter your SELECT Statement “Select col1,col2 from table_name”, conn

do until rs.EOF

‘Output to browser

response.write (“Col1 and Col2 Values” & rs(“col1”) & rs(“col2″) &”<BR>”)

‘Move to the Next Record in the database




‘Close connection



To contact the author please click here

More Tutorials from this author can be found at

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top