简体   繁体   中英

ODBC DSN Connection Error - SQL Server 2014 Express Classic ASP

Trying to connect a classic asp page to sql server express 2014 using a dsn.

I've created a new database (in sql server management studio) called warehouse , with a table called users . I've added a new login called user1 with a password and mapped it to the warehouse database

I've created an ODBC System DSN on the same machine, using sql server native client 11 driver called SQLServer2 with integrated windows authentication, and a default database warehouse . Testing the connection at this point works fine!

On the ASP page I'm using:-

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "dsn=SQLServer2;uid=user1;pwd=xyz;"

Error:- Microsoft OLE DB Provider for ODBC Drivers error '80040e4d'

[Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot open database "warehouse" requested by the login. The login failed.

I'm pretty sure that its a permissions issue and that the connection string is OK otherwise but after hours and hours of trying different strings, different users, I can't seem to get the damn thing to connect

If Anyone can throw any ideas my way I'd be very grateful. Thanks!

The way you are describing the problem the DSN uses integrated security so your credentials might be ignored and the database is called using the application pool identity.

If you have no specific reason why you need to use a DSN I would recommend using a connection string like the following:

objConn.Open "Provider=sqloledb;Server=yourdbserver;uid=user1;pwd=xyz;Database=warehouse"

A look into your SQL server log might give you a hint as to which user is actually failing to connect to your database.

I think you should have done something like this

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString "dsn=SQLServer2;uid=user1;pwd=xyz;"
objConn.open

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM