Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2004, 05:31 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecting to Access Db

Hi,

I'm using the following code to try and connect to a simple access db, but i keep getting an error.

The weird thing is it works fine on my test server , but when i upload to my webspace it just wont work. I've double checked the connection string too.

I've included the error and the code below, hope you can help.

error

Code:
Microsoft JET Database Engine error '80040e14' 

Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'. 

/testasp.asp, line 19
Page code

Code:
<%Option Explicit%>
<HTML>
<HEAD>
<TITLE>Testing our connection</TITLE>
</HEAD>
<BODY>

<%
Dim objConn, objRS
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")

objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
               "Data Source=d:/webspace/w00t.biz/db/newsletter.mdb;" & _
               "Persist Security Info=False"



objRS.Open "newsletter", objConn

While Not objRS.EOF
  Response.Write objRS("email") & "<BR>"
  objRS.MoveNext
Wend

objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing 
%>

</BODY>
</HTML>
 
Old October 13th, 2004, 07:47 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

instead of

objRS.Open "newsletter", objConn

try adding

objRS.Open "select * from newsletter", objConn

Note:


When opening a recordset you can pass an optional CommandTypeEnum value
(eg adCmdText, adCmdTable or adCmdStoredProc) to ADO to help it identify the source of your data.

If you choose to specify a database table as your data source, but pass the CommandTypeEnum value for adCmdText,
then you will receive the following error message. Either change the CommandTypeEnum to adCmdTable or adCmdTableDirect -or-
use an SQL query as the source of your recordset.

Om Prakash
 
Old October 13th, 2004, 09:15 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Mentiri, Muara, Brunei.
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

hi mattastic,

   Om prakash is right. U try that way.
And i would like to suggest one more thing. Why are you using physical path in the connection string?

It will not work outside your LAN.

Instead, use server.mappath(dbname)


----------
Rajani

 
Old October 14th, 2004, 02:32 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help





Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble connecting to Access DB thru IIS swoopest Classic ASP Databases 6 November 10th, 2004 10:13 AM
Connecting to Access via OLE-DB mairejo Access 3 October 26th, 2004 02:28 PM
Connecting VB Proj to a local Access DB jpaulptr Access VBA 0 May 27th, 2004 12:30 PM
Connecting to another Access db with different IP ckentebe Access VBA 3 April 21st, 2004 12:08 AM
Connecting to Access DB using Visual Basic .NET Lieth Access 6 September 26th, 2003 06:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.