简体   繁体   English

在SQL Server 2008 R2中复制数据库问题

[英]Copying db in SQL Server 2008 R2 issue

I've made a copy of a database in SQL Server R2 for dev purposes using the wizzard. 我已经使用向导在SQL Server R2中为开发目的制作了一个数据库副本。 That part worked fine. 那部分工作正常。 In my code, I've changed the connection string in web.config to point to the new db: 在我的代码中,我更改了web.config中的连接字符串以指向新的数据库:

<add name="myConnectionString" connectionString="Data Source=\dev;Initial Catalog=live_DEV;Integrated Security=True" providerName="System.Data.SqlClient"/>
<!--<add name="liveConnectionString" connectionString="Data Source=\dev;Initial Catalog=live;Integrated Security=True" providerName="System.Data.SqlClient"/>-->

I've changed the actual names of the servers etc. for security reasons but the format is the same. 为了安全起见,我已经更改了服务器等的实际名称,但是格式是相同的。 As you can see, I've commented out the old db and changed to a copy. 如您所见,我已经注释掉了旧数据库并更改为副本。

I'm using VS2010 and have changed all references from the old connection to my dev copy: 我正在使用VS2010,并将所有引用从旧连接更改为我的开发副本:

using (SqlConnection connIncident_TrackerDB = new SqlConnection(@"Data Source=\dev;Initial Catalog=live_DEV;Integrated Security=True"))
    {

I've checked the stored procedures in my dev copy which all have [USE live_DEV] as a header. 我已经检查了我的开发副本中的存储过程,这些存储过程都具有[USE live_DEV]作为标题。 I've cleaned and rebuild the code. 我已经清理并重建了代码。 I've restarted my ASP.NET Development Server and ran it. 我已经重新启动了ASP.NET开发服务器并运行了它。

When I do and check the databases, it's updating both live and dev copies. 当我检查数据库时,它会同时更新实时副本和开发副本。 What am I missing? 我想念什么?

thanks, Paul 谢谢保罗

Sounds like you missed some place in the code where the connection string has been hard coded. 听起来好像您错过了在代码中硬编码连接字符串的某个位置。 I suggest 2 things 我建议两件事

First change your privileges to disallow access to production. 首先,更改您的特权以禁止访问生产。 This will keep you from accidentally updating production with test code. 这样可以避免意外地使用测试代码更新产品。 And it will cause your app to break wherever production is getting updated (This might lead you to the cause of the problem). 并且这将导致您的应用在生产更新的任何地方中断(这可能会导致问题的原因)。

Second remove all hard coded connection strings from the app and only use the connection string in the web.config 其次,从应用程序中删除所有硬编码的连接字符串,仅使用web.config中的连接字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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