如何将数据插入到asp中不同位置的两个数据库中 [英] how to insert data into two database which are at different locations in asp

查看:73
本文介绍了如何将数据插入到asp中不同位置的两个数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我正在为文档管理系统开发一个Web应用程序。这里我的要求是我想在不同位置的两个sql服务器上保存数据

1)第一个sql server是我的localhost

2)第二个sql server是一个我托管了我的网站。

i希望在两台服务器上同时保存数据。请告诉我如何实现这一点并给我最简单的解决方案。

hello, i am developing a web application for document management system. here my requirement is i want to save data at two sql servers at different location among which
1)first sql server is my localhost
2)second sql server is the one where i have hosted my website.
i want to save data simultaneously at both the servers. pls tell me how can i achieve this & give me easiest solution .

推荐答案

在<$中定义两个 ConnectionStrings c $ c> web.config 文件,一个用于 localhost 以及该外部数据库的其他文件。



现在,在进行数据库操作时,首先使用 localhost 初始化 SqlConnection 类并执行所需的操作命令。然后使用外部数据库 ConnectionString 初始化相同的 SqlConnection 类或另一个,并执行命令。
Define two ConnectionStrings in web.config file, one for localhost and other for that external database.

Now, while doing database operations, just initialize the SqlConnection class with localhost first and execute the required command. Then initialize the same SqlConnection class or another with the external database ConnectionString and execute the command.


参考



http://www.dotnetspark.com/kb/780-how-to-use-multiple-database-connection.aspx [ ^ ]



希望这有助于......
Refer

http://www.dotnetspark.com/kb/780-how-to-use-multiple-database-connection.aspx[^]

Hope this helps...


这篇关于如何将数据插入到asp中不同位置的两个数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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