ASP Database connection problem

R

Ray

I'm following a tutorial in http://www.aspronline.com/learn/ and I'm trying
to connect to a database. The database is one I've used in a Front Page
Database Results Wizard, but I what to work out for myself how this all
works, without using wizards. So, that being the case, I've typed in what
they said, with my own own site and database specific stuff, but it doesn't
seem to work. This is what I've typed in:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
myDSN = "DRIVER={Microsoft Access Driver (\fpdb\books.mdb)};"
myDSN = myDSN & "DBQ=\fpdb\books.mdb"
Conn.Open(myDSN)
Conn.Close
Set Conn = Nothing
%>

<html><head>
<title>test.asp</title><meta name="Microsoft Theme" content="books-theme
1011, default">
</head>
<body color="#FFFFFF">

</body></html>

Can anybody help?

Ray
 
R

Ray

Right, I've now got the following:
<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "\fpdb\books.mdb"
Conn.Close
%>

<html><head>
<title>test.asp</title><meta name="Microsoft Theme" content="books-theme
1011, default">
</head>
<body color="#FFFFFF">

</body></html>
but I still get an error. The error is: HTTP 500 - Internal server error.
I'm sure I'm doing something really stupid, but please excuse me bacause I
am really new to this.
 
R

Ray

The real error is:
Microsoft VBScript runtime error '800a01a8'

Object required: 'Conn'

/notjustbooks/test.asp, line 2
 
R

Ray

I'm going through a tutorial, and the first step to is just open the
database. As you can see, I've got a long way to go!
 
B

Bob Barrows [MVP]

Ray said:
Right, I've now got the following:
<%

Don't forget to declare your variables. Use Option Explicit (it needs to be
the first line in your code) to avoid errors.

Option Explicit
dim conn
Set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "\fpdb\books.mdb".
It won't find this database file - you need to supply the full filesystem
path to it. You can use Server.Mappath for this.

This is how I usually do it:

dim sConnect
sConnect ="Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("\fpdb\books.mdb")
conn.Open sConnect

HTH,
Bob Barrows
 
R

Ray

The error makes more sense now. I'm getting this error:
Microsoft JET Database Engine error '80004005'

'c:\windows\system32\inetsrv\f\pdb\books.mdb' is not a valid path. Make sure
that the path name is spelled correctly and that you are connected to the
server on which the file resides.

/notjustbooks/test.asp, line 4

with this code

<%
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "f\pdb\books.mdb"
Conn.Close
Set Conn = Nothing
%>

<html><head>
<title>test.asp</title><meta name="Microsoft Theme" content="books-theme
1011, default">
</head>
<body color="#FFFFFF">

</body></html>

The thing is though that I'm publishng this to the internet, I'm not using
it on my local web. So why is it referring to 'c:\windows\system32\inetsrv?

Ray
 
B

Bob Barrows [MVP]

Ray said:
The error makes more sense now. I'm getting this error:
Microsoft JET Database Engine error '80004005'

'c:\windows\system32\inetsrv\f\pdb\books.mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.
I've already answered this.
 
R

Ray

....but now I get

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'Open'

/notjustbooks/test.asp, line 5

where line 5 = conn.Open sConnect


I'm sorry that this is so drawn out, and I really do appreciate your help

Ray
 
B

Bob Barrows [MVP]

I'm not looking over your shoulder. What does your code look like now? Did
you include the

Option Explicit
dim conn
Set conn=Server.CreateObject("ADODB.Connection")

lines? They should come before the conn.Open statement

Bob Barrows
 
R

Ray

Please do look over my shoulder, because I just want to get this working so
I can continue my tutorial.

It now looks like:
<%
Option Explicit
dim conn, sConnect

sConnect ="Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("\fpdb\books.mdb")
Set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open sConnect
conn.Close
Set conn = Nothing
%>

<html><head>
<title>test.asp</title><meta name="Microsoft Theme" content="books-theme
1011, default">
</head>
<body color="#FFFFFF">

</body></html>

and the error is

Microsoft JET Database Engine error '80004005'

Could not find installable ISAM.

/notjustbooks/test.asp, line 9
 
R

Roland Hall

: Please do look over my shoulder, because I just want to get this working
so
: I can continue my tutorial.
:
: It now looks like:
: <%
: Option Explicit
: dim conn, sConnect
:
: sConnect ="Microsoft.Jet.OLEDB.4.0;" & _
: "Data Source=" & Server.MapPath("\fpdb\books.mdb")
: Set conn=Server.CreateObject("ADODB.Connection")
: conn.Provider="Microsoft.Jet.OLEDB.4.0"
: conn.Open sConnect
: conn.Close
: Set conn = Nothing
: %>

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
Dim conn, sConnect
Set conn = Server.CreateObject("ADODB.Connection")
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("\fpdb\books.mdb")
conn.Open(sConnect)
conn.Close
Set conn = nothing
%>

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
B

Bob Barrows

Ray said:
Please do look over my shoulder, because I just want to get this
working so I can continue my tutorial.

It now looks like:
<%
Option Explicit
dim conn, sConnect

Oops - I forgot to correct your slashes. Server.MapPath requires a url as
the argument.

Not this:
sConnect ="Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("\fpdb\books.mdb")
Set conn=Server.CreateObject("ADODB.Connection")

This:
sConnect ="Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("/fpdb/books.mdb")



This line needs to go:
**************************************
conn.Provider="Microsoft.Jet.OLEDB.4.0" **************************************
conn.Open sConnect
conn.Close
Set conn = Nothing
%>

<html><head>
<title>test.asp</title><meta name="Microsoft Theme"
content="books-theme 1011, default">
</head>
<body color="#FFFFFF">

</body></html>

and the error is

Microsoft JET Database Engine error '80004005'

Could not find installable ISAM.

That error is covered is in this article:
http://www.aspfaq.com/show.asp?id=2009 - 80004005 errors

HTH,
Bob Barrows
 
R

Ray

With:
<%
Option Explicit
Response.Buffer = True
Dim conn, sConnect
Set conn = Server.CreateObject("ADODB.Connection")
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("\fpdb\books.mdb")
conn.Open(sConnect)
conn.Close
Set conn = nothing
%>
I now get:

Microsoft VBScript compilation error '800a03ea'

Syntax error

/notjustbooks/bbarrow.asp, line 6

sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
------------------------------------------------------------^If I take away
the "&", I get:

Provider error '80040e4d'

Authentication failed.

/notjustbooks/bbarrow.asp, line 8

I think I might give up! It all works fine using ASP if I use Front Page
generated stuff. Do I have a problem with my server?
 
B

Bob Barrows [MVP]

Ray said:
With:
<%
Option Explicit
Response.Buffer = True
Dim conn, sConnect
Set conn = Server.CreateObject("ADODB.Connection")
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("\fpdb\books.mdb")

It should look like this:

sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("/fpdb/books.mdb")

Make sure you use front-slashes (/) in the MapPath argument, not
back-slashes.

To further debug this, do:

Response.Write sConnect
Response.End

Run the page and make sure that MapPath has returned the correct filesystem
path for your database.

Bob Barrows
 
R

Ray

......now it says
Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Websites\hdo212\notjustbooks\fpdb\books.mdb

which is wrong! It seems to be looking on my local system rather than my web
server. But it's progress!
 
R

Roland Hall

in message
: Ray wrote:
: > With:
: > <%
: > Option Explicit
: > Response.Buffer = True
: > Dim conn, sConnect
: > Set conn = Server.CreateObject("ADODB.Connection")
: > sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
: > Server.MapPath("\fpdb\books.mdb")
:
: It should look like this:
:
: sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
: "Data Source=" & Server.MapPath("/fpdb/books.mdb")
:
: Make sure you use front-slashes (/) in the MapPath argument, not
: back-slashes.
:
: To further debug this, do:
:
: Response.Write sConnect
: Response.End
:
: Run the page and make sure that MapPath has returned the correct
filesystem
: path for your database.

Sorry about that Ray. I never use Server.MapPath to access my db files
since they are all outside the web root so I missed the \ reference you were
using. Thanks to Bob for catching that. I would have corrected it after I
saw his other post but I thought you would make that connection from his
post.


--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top