Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't connect to or read from database

Status
Not open for further replies.

LaPluma

Programmer
Feb 3, 2002
139
DE
Hello

I have some code - which I thought was quite straightforward! I am trying to connect to a MSAccess2000 database and to read a couple of fields in the database. It doesn't seem to work, and I wondered what I was doing wrong.

The code is:

<%
Option Explicit

Dim ConnectionString
Dim connObj
Dim sql
Dim oRS


ConnectionString=&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & Server.MapPath(&quot;\testDB.mdb&quot;) & &quot;;

Set ConnObj = Server.CreateObject(&quot;ADODB.Connection&quot;)
connObj.Open ConnectionString

sql = &quot;select * from Table1&quot;
Set oRS = connObj.Execute(sql)
Do While Not oRS.EOF
Response.Write(oRS(&quot;girlFirst&quot;) & &quot; - &quot; & oRS(&quot;girlSurname&quot;) & &quot;<br>&quot;)
oRS.MoveNext
Loop

oRS.Close
connObj.Close


Set oRS = Nothing
Set connObj = Nothing
%>

The error message I am getting (though I am not sure if this is the reason why I don't seem able to connect to the DB or read from it) is:

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/stevehigham/db/test.asp, line 10

ConnectionString=&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & Server.MapPath(&quot;\testDB.mdb&quot;) & &quot;;
-----------------------------------------------------------------------------------------------------^

Thank you for any help.

LaPluma

 
ConnectionString=&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & Server.MapPath(&quot;\testDB.mdb.mdb&quot;) & &quot;;&quot;

You were missing a &quot; at the end Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
Hello Gary

Many thanks for your message.

The main problem was something to do with the path, but none of it would have worked, of course, without the little &quot;.

Thanks for your help.

Best wishes

LaPluma
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top