Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Help connecting to Access DB

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,1908
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Help connecting to Access DB
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Help connecting to Access DB - 1/26/2005 3:28:42 AM   
  Basil the Fox

 

Posts: 1
Score: 0
Joined: 1/26/2005
From: United Kingdom
Status: offline
Hi I'm following a tutorial on ASP using VBSCRIPT and have typed up the example code which should connect to my database, retrieve information, then display it on the page. Unfortunately it's not working for me, I am getting a page cannot be displayed error, along with the following:

"Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/mick/test/databasecon.asp, line 5, column 58".


I really can't work out what the problem is. Can anyone here help me?
The only thing I've done differently to the example code (demo files aren't provided with my tutorial) is to use my own access database file and refer to tables and fields within that. NB My database is stored in the root directory of my site (if you can call it that at this stage).

Here's my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">

<%@LANGUAGE="VBSCRIPT"%>

<%Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="&_Server.MapPath("db1.mdb")
SQL="select Customer Name,JSH Design Number from Worksheet"
set RSworksheet = Conn.execute (SQL)%>

<html>
<head>
<title>Connect to Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table border="1" bordercolor="black" cellpadding="0" cellspacing="0" width="400">
<tr>
<td><b>Customer</b></td>
<td><b>Design Number</b></td>
</tr>
<%while not RSworksheet.BOF and not RSworksheet.EOF%>
<tr><td><%=RSworksheet("Customer Name")%></td>
<tr><td><%=REworksheet("JSH Design Number")%></td>
</tr>
<%Worksheet.movenext
wend%>
</table>
<%Conn.close%>
</body>
</html>

Thanks in advance for any help you can give.
 
 
Post #: 1
 
 Re: Help connecting to Access DB - 3/2/2005 11:15:29 PM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Dear Basil the Fox,
There r some mistakes, so i will give u the complete correct code.
PLZ Note that it is a bit diffrent from urs. And i personaly recommend u to use my way since u r a biggener:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">

<%@LANGUAGE="VBSCRIPT"%>

<%
Dim Conn
Dim RSworksheet

Set Conn=Server.CreateObject("ADODB.Connection")
Conn.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("/db1.mdb")
Conn.Open
Conn.BeginTrans
set RSworksheet = server.CreateObject("ADODB.Recordset")
set RSworksheet.ActiveConnection =Conn
objCon.CommitTrans
objRs.Open "SELECT Customer Name,JSH Design Number FROM Worksheet",Conn,2,3
%>

<html>
<head>
<title>Connect to Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table border="1" bordercolor="black" cellpadding="0" cellspacing="0" width="400">
<tr>
<td><b>Customer</b></td>
<td><b>Design Number</b></td>
</tr>
<%Do until RSworksheet.EOF%>
<tr><td><%response.write RSworksheet.Fields("Customer Name")%></td>
<tr><td><%response.write RSworksheet.Fields("JSH Design Number")%></td>
<%RSworksheet.movenext
loop%>
</tr>
</table>
<%
RSworksheet.close
Conn.close
set RSworksheet=nothing
set Conn=nothing%>
</body>
</html>


Don't Forget to post the results

Best Regards

Firas S Assaad

(in reply to Basil the Fox)
 
 
Post #: 2
 
 Re: Help connecting to Access DB - 3/2/2005 11:17:06 PM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Sorry the code is this :


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">

<%@LANGUAGE="VBSCRIPT"%>

<%
Dim Conn
Dim RSworksheet

Set Conn=Server.CreateObject("ADODB.Connection")
Conn.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("/db1.mdb")
Conn.Open
Conn.BeginTrans
set RSworksheet = server.CreateObject("ADODB.Recordset")
set RSworksheet.ActiveConnection =Conn
Conn.CommitTrans
RSworksheet.Open "SELECT Customer Name,JSH Design Number FROM Worksheet",Conn,2,3
%>

<html>
<head>
<title>Connect to Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table border="1" bordercolor="black" cellpadding="0" cellspacing="0" width="400">
<tr>
<td><b>Customer</b></td>
<td><b>Design Number</b></td>
</tr>
<%Do until RSworksheet.EOF%>
<tr><td><%response.write RSworksheet.Fields("Customer Name")%></td>
<tr><td><%response.write RSworksheet.Fields("JSH Design Number")%></td>
<%RSworksheet.movenext
loop%>
</tr>
</table>
<%
RSworksheet.close
Conn.close
set RSworksheet=nothing
set Conn=nothing%>
</body>
</html>

(in reply to Basil the Fox)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Help connecting to Access DB Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts