IXMonkey
IXMonkey

Reputation: 1

Connecting to SQL Server 2005 using classic ASP

I have installed both IIS and SQL Server 2005 on my laptop.

Both work individualy, however when I try to connect to an DB from an ASP page I keep getting the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database "DB1" requested by the login. The login failed.

/testFiles/Connection/Connection.inc, line 5

Line 5 says:

con.open "DSN=DB1"

Can anybody tell me what the problem is?

Thanks

Upvotes: 0

Views: 1978

Answers (2)

Rob
Rob

Reputation: 164

Your Connection string "DSN=DB1" is lacking credentials at the minimum (which is why the login failed)

www.connectionstrings.com is a very useful website that will help you construct your connection string. You can select the DB you are working with and provide the details (server,DB, username,password,dsn.....) and it will help give you back the connection string.

Upvotes: 0

Dustin Laine
Dustin Laine

Reputation: 38503

Below is a sample, but I think you are having a problem with credentials. Go through the configuration of the DSN and make sure it connects.

set conn = server.createobject("ADODB.Connection")
set rsuser= server.createobject("ADODB.Recordset")
conn.open CONNECTIONSTRING
sql="SELECT * FROM Table"
rsuser.Open sql,conn,1,2
rsuser.close
set rsuser = nothing
conn.close
set conn = nothing

Upvotes: 2

Related Questions