Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a connection to a database

Status
Not open for further replies.

RussOSU

Technical User
Apr 16, 2001
93
US
I am trying to connect a form in which I created to a database. I am doing this by sending the form data to a .asp page and having the .asp page display and then create a new entry in the database. I have the ODBC resource created on our intranet server. The resource is named FolderRequests. I have created the connection string but get an error and can not figure out what the problem is. I am a newbie to this still. The connection string I have and the error are below. Any help would be appreciated.

-----------------------------------------------------------

39 Dim objConn
40
41 'Create a connection to the database
42 Set objConn = Server.CreateObject("ADODB.Connection")
43
44 'Open the connection
45 objConn.Open "DSN=FolderRequests","",""

--> I have also tried with
objConn.Open "DSN=FolderRequests"

-----------------------------------------------------------
The error I get is

Microsoft VBScript runtime error '800a01ad'

ActiveX component can't create object

/dds/DDS_Organized/MAI Output.asp, line 45

-----------------------------------------------------------

The database is an Access 2000 database with only 1 table named MAIReq. The Database itself is called FolderRequest.mdb. I don't think that the resource itself is the problem since it was created the same way that all of our other resources have been which are working properly.

Thanks
Russ


 
Where is the DSN actually located? It should be on the server that runs the ASP, not the client...

Kevin
 
I am not really sure how to find out where the DSN is located. However due to the fact it was created the same way as the other ones that we have running I would believe it is on the server with the .asp. Is there a way I can check?

Thanks
Russ
 
You will have to have a user account with administrator (or power user, depending on how security is set up) permissions. Then it depends on the OS. From the server:

Win 2000 -
Go to the start menu, Settings, Taskbar & Start Menu.
Click on the Advanced tab.
On Start Menu Settings (at the bottom), ensure "Display Administrative Tools" is checked.
Click OK.
Go back to the start menu, Programs, Administrative Tools, and Click on Data Sources(ODBC)

NT 4.0
Go to the Start menu, Settings, Control Panel.
Load Data Sources(ODBC)

Now -
The ODBC screen is identical for both OS's. Click on the System DSN tab. see if the DSN (FolderRequests) is listed. If it is, beats me, should work. If it's not, check File DSN and see if it's listed there. If it is, change your line 45 to
Code:
objConn.Open "FileDSN=FolderRequests","",""
If by some dumb chance, it is listed under User DSN, move it to System DSN or File DSN by deleting it and re-creating it.

Also - be sure the server can see the database. If the database is Access, this means that the .MDB should be on a local (to the server) hard drive, or a permanently mapped network drive.

Good luck,
Kevin
 
Here is a example that I used to create a connection between a ASP page and a MS Access 2000 DB. This should help, all you should have to do is change the file location to match your DB....

inputdsn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\web.mdb;Persist Security Info=False"

set ConnUD=server.createobject("adodb.connection")

ConnUD.open inputdsn

Hope this helps.
 
Dynapen I tried your connection string and got the same thing as above. This seems very weird that I am unable to connect to the page. If anyone has any other ideas I am open to suggestions.

Thanks
Russ
 
Here's a silly thought:
If you can create an ADO Recordset object (line 42), but can't open the dsn (line 45), maybe Access security is kicking in and won't let you open it without user persmissions. Try this in plain text:

Code:
45    objConn.Open "DSN=FolderRequests;","myUsername","MyPassword"[code]

replace my userid and password with whatever your windows login userid and password are.  Also, try adding the semicolon (;) to the end of the statement, even if you only say "DSN=FolderRequests;"

Also try using FileDSN= and also UserDSN= and SystemDSN=, maybe the computer is getting confused.
 
This is a re-occurring question. See thread333-117566 Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top