views:

352

answers:

2

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

+2  A: 

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
Dustin Laine
A: 

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.

Rob