Connecting Tech Pros Worldwide Help | Site Map

ASP Database connectity

Member
 
Join Date: Aug 2006
Posts: 110
#1: Mar 6 '09
Hi Friends,

I am very new to ASP and trying to connect a database with Ms-Access with DSN. I have setup the DSN into my hosting account. I don't know how to connect with the database in the ASP. Here is the code I am trying to use:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Set oConnection = Server.CreateObject("ADODB.Connection")
  3. oConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
  4. Server.MapPath("") & ";"
  5. oConnection.Close
  6. Set oConnection = Nothing
  7.  
  8.  
and I am also getting a Server error which is:

500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed.


Please help me in this.

Thanks

Deepak
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#2: Mar 9 '09

re: ASP Database connectity


Quote:

Originally Posted by deepaks85 View Post

500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed.

This error is very ambiguous. You need to turn off the "friendly error messages" to find out what the real problem is.

To get the actual error to display, try removing all code (control + x to copy it all to the clipboard for later) write a basic hello world web page and save, hit trefresh to see the hello world, then re-paste your page, save and refresh again. This should show the actual error message.

Jared
Expert
 
Join Date: Nov 2007
Posts: 126
#3: Apr 16 '09

re: ASP Database connectity


If you already have a DSN setup, you are using the wrong type of connection string. Try the following, substituting your DSN for my sample one.

Expand|Select|Wrap|Line Numbers
  1. set conn=Server.CreateObject("ADODB.Connection")
  2. conn.Provider="Microsoft.Jet.OLEDB.4.0"
  3. conn.Open "sample"
  4.  
  5. conn.close
  6. set conn = nothing
  7.  
Reply