Print Page | Close Window

ASP/Access database

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=18444
Printed Date: 29 March 2026 at 4:24pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP/Access database
Posted By: milty456
Subject: ASP/Access database
Date Posted: 20 February 2006 at 1:24am
Hello,

I am writing  an asp page with vbscript.  My code is working the first time.   The next time i reload or come back to the page and try it again, it errors out on the  connection object .open method.

If i wait like 30 seconds, and try again, it will work again.  Is there some timer or property of the connection object i am missing?

<%

Dim objconn, cn, dbPath
dbPath="DrDb.mdb"

Set ObjConn= Server.CreateObject("ADODB.Connection")
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(dbPath)
ObjConn.connectionstring = cn


ObjConn.open

dim rs
set rs = server.CreateObject("ADODB.Recordset")
rs.Open "SELECT * FROM PaInfo", ObjConn

response.write "The SS is " & rs.fields("SSNo").value

rs.Close
set rs = nothing



ObjConn.Close
Set ObjConn = nothing

Thanks




Replies:
Posted By: dpyers
Date Posted: 20 February 2006 at 2:10am
You're doing a response.write of the rs.fields after you close the rs. Don't know why it works the first time.
Also, use the Jet 4.0 driver instead of the Microsoft Access Driver. The Microsoft Access Driver is several versions old and buggy.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: milty456
Date Posted: 20 February 2006 at 3:06am
Sorry, i posted that response.write after the fact...it is not located there it is before i close it....what is the proper sytax for the jet driver?


Posted By: padoxky
Date Posted: 21 February 2006 at 2:43pm

Try using jet 4 driver

 
<%
Dim objConn
Dim cn
Dim strPathDb


 strPathDb = Server.MapPath("database/mydbname.mdb")

Set objConn = Server.CreateObject("ADODB.Connection")
cn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strPathDb
objConn.connectionstring = cn
objConn.Open

strSQL = "SELECT * From PaInfo"
set rs = cn.execute(strSQL)
 
%>

<html>
<head>
<title></title></head>
<body>

  This SS is <%=rs("SSNO")%>


</body>
</html>

<%
rs.Close
set rs = nothing
Set objConn = nothing
%>


-------------
NgWebDesigns



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net