在另一个DB上执行应用程序时保存到另一个DB中的表 [英] Save to a table in another DB while executing application on another DB

查看:98
本文介绍了在另一个DB上执行应用程序时保存到另一个DB中的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个关于以下情况的帮助,请..



我正在使用ASP.net C#应用程序连接到带有DB的sql 2008 R2说myTestDB。我的应用程序是在这个数据库中的表上插入,更新和删除。



现在我需要实现一个逻辑,在某些条件下,数据将被保存到另一个数据库中的表-say mySecondDB





我知道我们可以在web.confing中处理不同的连接字符串通过插入inti mysecondDb.dbo.tablename



我不知道我们可以使用的任何其他选项。



请告知最佳和快速的方法。



提前致谢..

I need a help on the below situation,please..

I am working with ASP.net C# application which is connected to sql 2008 R2 with a DB say myTestDB. My application is inserting ,updating and deleting on the tables in this DB.

Now I need to implement a logic in which on certain conditions, the data will get saved to a table in another DB -say mySecondDB


I came to know that we can either handle different connection string in the web.confing to the "mysecondDB" and connect

or i can handle in the back end (SQL) by insert inti mysecondDb.dbo.tablename

I don't know any other option we can use.

Please advise the optimum and fast method for doing this.

Thanks in advance..

推荐答案

解决方案1:



不要在程序中使用database.owner.object,只使用owner.object并让连接选择数据库。然后你可以在调用程序之前轻松更改SqlConnection。



解决方案2:



如果你喜欢让数据库的副本使用副本,并在数据库服务器中设置复制规则。
Solution 1:

Do not use database.owner.object in your procedures, use only owner.object and let the connection to select the database. Then you can easily change SqlConnection before calling the procedure.

Solution 2:

If you like to have a copy of your database use a replica, and set the replication rules in the database server.


这篇关于在另一个DB上执行应用程序时保存到另一个DB中的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆