Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP/Access database
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP/Access database

 Post Reply Post Reply
Author
milty456 View Drop Down
Newbie
Newbie


Joined: 20 February 2006
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote milty456 Quote  Post ReplyReply Direct Link To This Post Topic: ASP/Access database
    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



Edited by milty456 - 20 February 2006 at 3:07am
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
milty456 View Drop Down
Newbie
Newbie


Joined: 20 February 2006
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote milty456 Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
padoxky View Drop Down
Groupie
Groupie
Avatar

Joined: 17 June 2004
Location: Nigeria
Status: Offline
Points: 78
Post Options Post Options   Thanks (0) Thanks(0)   Quote padoxky Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.