Trying to connect a classic asp page to sql server express 2014 using a dsn.
尝试使用dsn将经典的asp页面连接到sql server express 2014。
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
我创建了一个名为warehouse的新数据库(在sql server management studio中),其中有一个名为users的表。我添加了一个名为user1的新登录密码,并将其映射到仓库数据库
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!
我在同一台机器上创建了一个ODBC系统DSN,使用带有集成Windows身份验证的SQL Server2 sql server本机客户端11驱动程序和一个默认数据库仓库。此时测试连接工作正常!
On the ASP page I'm using:-
在我正在使用的ASP页面上: -
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 OLE DB Provider for ODBC Drivers错误'80040e4d'
[Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot open database "warehouse" requested by the login. The login failed.
[Microsoft] [SQL Server Native Client 11.0] [SQL Server]无法打开登录请求的数据库“仓库”。登录失败。
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!
如果任何人都可以按我的方式提出任何想法,我将非常感激。谢谢!
2 个解决方案
#1
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.
您描述问题的方式是DSN使用集成安全性,因此可能会忽略您的凭据并使用应用程序池标识调用数据库。
If you have no specific reason why you need to use a DSN I would recommend using a connection string like the following:
如果您没有具体原因需要使用DSN,我建议您使用如下连接字符串:
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.
查看SQL服务器日志可能会提示您哪个用户实际上无法连接到您的数据库。
#2
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
设置objConn = Server.CreateObject(“ADODB.Connection”)objConn.ConnectionString“dsn = SQLServer2; uid = user1; pwd = xyz;” objConn.open
#1
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.
您描述问题的方式是DSN使用集成安全性,因此可能会忽略您的凭据并使用应用程序池标识调用数据库。
If you have no specific reason why you need to use a DSN I would recommend using a connection string like the following:
如果您没有具体原因需要使用DSN,我建议您使用如下连接字符串:
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.
查看SQL服务器日志可能会提示您哪个用户实际上无法连接到您的数据库。
#2
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
设置objConn = Server.CreateObject(“ADODB.Connection”)objConn.ConnectionString“dsn = SQLServer2; uid = user1; pwd = xyz;” objConn.open