Database Connectivity

M

MROPARTNER

Microsoft has a tutorial for ASP. There is a connection string in the
code
as follows:

DBQ=C:\Inetpub\Wwwroot\Tutorial\guestbook.mdb;"\

How do I change this statement once I move the page to my web server?
I
have the database in my root folder.


Thanks
 
R

Ray Costanzo [MVP]

Try using this, both locally and remotely:

Dim sConnectionString
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/tutorial/guestbook.mdb")

Note that unless you've configured IIS so that read-access is denied to that
file or directory via HTTP, anyone in the world can download your database.
(Assuming that directory is a WWW-published directory.)

Ray at work
 
J

Jeff Cochran

Try using this, both locally and remotely:

Dim sConnectionString
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/tutorial/guestbook.mdb")

As an explanation, Server.MapPath finds the actual physical path on
the system to the file beginning at the root of the web. So if your
file was physically at:

c:\inetpub\wwwroot\subfolder1\application\database.mdb

and your site's root was at:

c:\inetpub\wwwroot\

then the MapPath argument would be:

("/subfolder1/application/database.mdb")

Using MapPath ensure that the structure of your web site is followed,
no matter where the root of your site happens to be on the server.
Your ISP could have your root at H:\Webroots\BasicHostingPlans\Bob\
and as long as your structure of your site is the same as on your
home/development system you don't need to change the code.

Jeff
 
M

MROPARTNER

Jeff,

Do you offer consulting (tech support) by the hour? If so what is your
fee?

Thanks
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top