开发者

Connecting to SQL Server 2005 using classic ASP

开发者 https://www.devze.com 2022-12-24 15:36 出处:网络
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:

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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号