PDA

View Full Version : Connecting to Acces Database


juancarlosc
04-29-2004, 12:12 AM
Hi,

I am working on an internet survey using asp. My site is hosted on a server and I dont have permission to use ODBC, I already asked them to make the ODBC connection for me, they called it survey. I am using an access Database also.

I have been trying to connect to my database usind DSN connection:

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath(".") & "wsissurvey.mdb;" & "User Id=admin;" & "Password="

I turned off friendly messages and I keep getting this:

There was an error processing your request. Please contact an administrator from the contact page.

This survey has a sumbit button that calls another asp page that is supposed to make the connection and to introduce the information into the database. But I think that the problem is in the connection.

I just called the server administrators and the y told me that my ODBC is working perfect.
I have tried DSN and DSn less connections and the same message appears. Can you help me?

Thank you for your HElp

Juan Carlos

miranda
05-03-2004, 03:57 AM
to connect wiht the DSN use
oConn.open "DSN=survey"

to connect with a DSNless connection try this one instead of what you had
oConn.open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("wsissurvey.mdb") & ";")

M@rco
05-04-2004, 01:23 AM
This is a classic mistake - the Server.MapPath() function doesn't add a backslash to the end of a path, and so if (as an example) the current directory is "c:\site\www", the relevant snippet of the connection string ends up as:Data Source=c:\site\wwwwsissurvey.mdb;instead ofData Source=c:\site\www\wsissurvey.mdb;as you were expecting.

Since the MDB file is in the current folder, Miranda's solution is fine, but this also suggests that your MDB file is probably world readable (i.e. anybody could download it simply by accessing the right URL, such as "http://yoursite.com/wsissurvey.db"). This is NOT a good thing - the MDB file should be in a directory which is NOT world-readable, preferably outside of the web root entirely.

glenngv
05-04-2004, 04:53 AM
Since the MDB file is in the current folder, Miranda's solution is fine, but this also suggests that your MDB file is probably world readable (i.e. anybody could download it simply by accessing the right URL, such as "http://yoursite.com/wsissurvey.db"). This is NOT a good thing - the MDB file should be in a directory which is NOT world-readable, preferably outside of the web root entirely.

...and specifically just right above the web root. See this post (http://www.codingforums.com/showthread.php?s=&threadid=33092#postmenu_171536).