Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Problem connecting Sql and Access databases.


Message #1 by "Amit" <amit_articles@y...> on Mon, 8 May 2000 13:47:57
Hi !

I am having trouble connecting to Sql and Access databases. After I run the 

script it gives me an error saying :

     

     Microsoft JET Database Engine error '80004005' 

     Could not find file 'D:\WINNT\system32\ATable.mdb'. 

     /Test/Servelets/Connect.asp, line 39 



I have written the following code as my Asp program :

-----------

<%

Dim adOpenForwardOnly, adLockReadOnly, adCmdTable

adOpenForwardOnly = 0

adLockReadOnly = 1

adCmdTable = 2



Dim objConn, objRS

Set objConn = Server.CreateObject("ADODB.Connection")

Set objRS = Server.CreateObject("ADODB.Recordset")

Dim strDatabaseType

strDatabaseType = "Access"



If strDatabaseType = "Access" Then

objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _

               "Data Source=C:\Amit\ATable.mdb;" & _

               "Persist Security Info=False"

End If



  objRS.Open "ATable.mdb", objConn, adOpenForwardOnly, adLockReadOnly, 

adCmdTable



While Not objRS.EOF

  Response.Write objRS("Title") & "<BR>"

  objRS.MoveNext

Wend



objRS.Close

objConn.Close

Set objRS = Nothing

Set objConn = Nothing

%>

---------



Please guide me as to how I should resolve the problem. I have got IIS 

4.0,

Build (Build 1381 Service Pack 4.0), Microsoft Management Console 1.1



When I try to connect to SQL server 7.0 by using the following code,

-----

 objConn.Open "Provider=SQLOLEDB;Data Source=C:\Amit\model.mdf;" & _

               "Database=Model;User ID=WEB; Password="

-----

I get the following error :

-----

Microsoft OLE DB Provider for SQL Server error '80004005' 

[DBNMPNTW]Specified SQL server not found. 

-----

I know that the above is a bit long, but I wanted to provide you with all 

the data so that you can really pin-point the error I have made. Please 

help me resolve this as it is becoming very difficult for me to function 

without a database connection to my ASP program.



best regards,

Amit Dhand.

Message #2 by Kevin D Riggs <kevin.riggs@p...> on Mon, 08 May 2000 09:44:43 -0400
If you have access to the NT server then the easiest way to connect is to

create a DSN (Data Source Name) for your database and use the DSN to

connect.  That way you don't have to worry about Providers, etc.



	1) Open Control Panels

	2) Open the ODBC32 Contol panel

	3) Create a system DSN (second tab - then click the Add button)

	4) Point the new DSN to your database and give the DSN a name

	5) Click the OK buttons until you are out of ODBC32



	6) Reference your database with:



	objConn.Open "DSN=whatevernameyouchose"





This should open a connection to your DSN just like you were attempting

with the whole "Provider . . . ."

Same thing goes for SQL server.





KD



Kevin D Riggs



kevin.riggs@p...



Senior Network Administrator & Webmaster

Rhea County

Board of Education



http://www.rhea.k12.tn.us/

http://www.rheacounty.org/

Message #3 by "Ken Schaefer" <ken.s@a...> on Tue, 9 May 2000 10:25:57 +1000
Your problem is here:



> objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _

>                "Data Source=C:\Amit\ATable.mdb;" & _

>                "Persist Security Info=False"



Here you define the database to be opened as c:\amit\atable.mdb

but there later on you do this:



>   objRS.Open "ATable.mdb", objConn, adOpenForwardOnly, adLockReadOnly,

> adCmdTable



objRS.Open should have as it's first parameter a table, proc or SQL

statement, eg



objRS.Open table1, objConn, adOpenForwardOnly, AdLockReadOnly, adCmdTable



my guess is that you are trying to open a table (adCmdTable), however

ATable.mdb is not a valid table name in your database...



Cheers

Ken




  Return to Index