PDA

Click to See Complete Forum and Search --> : Database connection


Tricky
Jan 8th, 2001, 03:11 PM
I'm a newbie so sorry if this is simple...

I'm creating a simple online shopping site...

to connect to the database I have the lines

Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source='store.mdb'"
rs.Open strSQL,cn
rs.MoveFirst

when moved to a sever, the database i want to point to is at http://merlin/project2/store.mdb. I've tried replacing store.mdb with this path but i get the error messge 'C:\WINDOWS\Desktop\http:\\merlin\project2\onlinestore.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.

Any ideas would be greatly appreciated

parksie
Jan 8th, 2001, 03:13 PM
You need to reference the database using the path it's at on the server.

Tricky
Jan 8th, 2001, 03:18 PM
that is the path where its stored on the server....isnt it?

parksie
Jan 8th, 2001, 03:21 PM
Yep. Such as c:\websites\project2\data.mdb.

One suggestion - keep the database away from any external access (don't have it under a web-shared folder).

Tricky
Jan 8th, 2001, 03:40 PM
Sorry to keep on but....!!

it will be stored on the network server - merlin, in a directory off the root called Project2.

It needs to be accessed across a LAN so it will not be stored on a C drive.

It works fine if i move it around my drive C but when its uploaded to the server and I change the data source command, it doesnt like it!!

parksie
Jan 8th, 2001, 03:55 PM
Think of it from the ASP's point of view. What is the filename as it sees it?

Jan 8th, 2001, 03:56 PM
You should create DSN.
Go to control panel/ODBC data services/create DSN.

Tricky
Jan 8th, 2001, 04:15 PM
It works fine on a standalone PC with PWS installed - its when i have to copy it to the LAN (and therefore change the path of the data source).

Every time i change the path to the new path on the LAN it complains.....I'm not sure if theres any way I can change the syntax because by default, on the LAN, it always looks in a default dir..no matter what path I change it to - it just adds it onto the end of this default path c:\winnt

This helpfull?! I'm desperate!

Berthil
Jan 9th, 2001, 05:21 AM
You must use the Full path to your database on a server if you do not have a DSN. Like:

Source=Server.MapPath("/folder1/folder2/yourdata.mdb")

The folders must go back to the root, just ask the properties of the database on the server and you should see the full path to the root. Use that.

If you use the database connection in an Included file, don't call the file *.inc but *.asp. Is someone knows the *.inc location he can download the inc file and he knows your database location. *.asp can't be downloaded.