无法访问同一服务器上的重复 SQL Server 数据库

发布于 2024-09-25 07:05:43 字数 1058 浏览 0 评论 0原文

我在 Windows Server 2003 R2 上使用 SQL Server Workgroup Edition。

我的经典 ASP 页面使用系统 DSN 访问我的生产数据库。都在这里工作。

像这样的代码...

<%
dbName= "ProdDB"  
userID = "PublicUser"  
pwd = "PublicUserPW"

Set objConn = Server.createObject("ADODB.Connection")  
objConn.connectionString = "DSN=MySystemDSN"  
objConn.open dbName, userID, pwd  
%>  

ProdDB 在 Enterprise Manager 中创建了 ProdDB 的副本

  • 为了开发和测试,我通过备份
  • 从 ProdDB 备份集恢复到名为 TestDB 的新数据库

我的理解是,恢复的数据库将包含该数据库的精确副本数据以及用户、角色等。在企业管理器中比较这两个数据库似乎支持了这一假设。

所以...我假设我可以使用相同的凭据访问测试副本,并且只更改 dbName,就像这样...

<%
dbName= "TestDB"  
userID = "PublicUser"  
pwd = "PublicUserPW"

Set objConn = Server.createObject("ADODB.Connection")  
objConn.connectionString = "DSN=MySystemDSN"  
objConn.open dbName, userID, pwd  
%>  

但是,现在我的页面返回

[Microsoft][ODBC 驱动程序管理器] 数据 未找到源名称且无默认值 指定驱动程序

我什至尝试创建一个新的系统DSN,默认数据库指向TestDB。还是没有喜悦。

我确信我正在做一些简单而愚蠢的事情。非常感谢任何帮助。

I am using SQL Server Workgroup Edition on Windows Server 2003 R2

My classic ASP pages access my production database using a system DSN. All working here.

Code like this...

<%
dbName= "ProdDB"  
userID = "PublicUser"  
pwd = "PublicUserPW"

Set objConn = Server.createObject("ADODB.Connection")  
objConn.connectionString = "DSN=MySystemDSN"  
objConn.open dbName, userID, pwd  
%>  

For development and testing, I created a copy of ProdDB in Enterprise Manager by

  • Backing up ProdDB
  • Restoring from the ProdDB backup set to a new database called TestDB

My understanding was that the restored database would contain an exact copy of the data as well as users, roles etc. Comparing both databases in Enterprise Manager seemed to back up this assumption.

So... I assumed I can access the test copy using the same credentials and only change the dbName, like so...

<%
dbName= "TestDB"  
userID = "PublicUser"  
pwd = "PublicUserPW"

Set objConn = Server.createObject("ADODB.Connection")  
objConn.connectionString = "DSN=MySystemDSN"  
objConn.open dbName, userID, pwd  
%>  

However, now my page returns

[Microsoft][ODBC Driver Manager] Data
source name not found and no default
driver specified

I have even tried creating a new System DSN, with a default database pointing at TestDB. Still no joy.

I'm sure I'm doing something simple and silly. Any assistance gratefully received.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒江雪… 2024-10-02 07:05:43

open 方法 的文档表示它已声明:

connection.Open ConnectionString, UserID, Password, Options

所以看起来您是传入 TestDB 作为连接字符串。我通常调用 open 而不指定任何参数。从 connectionstrings dot com 获取连接字符串,并且:

objConn.ConnectionString = "Data Source=localhost;Initial Catalog=testdb;" & _
    "User Id=myUsername;Password=myPassword;"
objConn.Open

The documentation for the open method says it's declared:

connection.Open ConnectionString, UserID, Password, Options

So it looks like you're passing in TestDB as the connection string. I usually call open without specifying any arguments. Grab a connection string from connectionstrings dot com, and:

objConn.ConnectionString = "Data Source=localhost;Initial Catalog=testdb;" & _
    "User Id=myUsername;Password=myPassword;"
objConn.Open
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文