在C#Windows应用程序中连接两个数据库 [英] connect two databases in c# windows application

查看:269
本文介绍了在C#Windows应用程序中连接两个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

现在我在连接两个数据库时遇到了一些问题.这里一个是服务器,另一个数据库是客户端.所有过程都在客户端进行,并存储在Client_DB中,同时该数据存储在Server_DB中.我的应用程序有10多个客户.因此Server_DB存储了所有Clients_DB信息并标识了每个客户端.这里使用的是SQL Server 2005 Management Studio.

在我上面的问题中,我不知道一个提示.这里我的问题是1.如何连接两个数据库2.如何从客户端到服务器传输数据3.服务器如何识别谁是客户端(Clent1,Client2 ... Client10).

在此先感谢

Dhinesh Kumar.V

Hi all,

Now i have some problem while connect two databases. Here one is Server and other DB is Client. All process going at client and stored Client_DB, Meanwhile that data is stored in Server_DB. My application more than 10 clients. So the Server_DB stored all Clients_DB information as well as identify each Client.. Here am using SQL Server 2005 Management studio.

In my above problem, i dont know the single tip. here my question is 1.How connect two databases 2.How transfer data from client to Server 3.How the server identify who is client(Clent1,Client2...Client10).

Thanks in Advance

Dhinesh Kumar.V

推荐答案


您可以使用SQL Server Replication
http://msdn.microsoft.com/en-us/library/ms151198.aspx [ ^ ]

> http://stackoverflow. com/questions/153988/how-can-i-copy-data-records-between-two-instances-of-an-sqlserver-数据库 [
Hi ,
you can use SQL Server Replication
http://msdn.microsoft.com/en-us/library/ms151198.aspx[^]
or
http://stackoverflow.com/questions/153988/how-can-i-copy-data-records-between-two-instances-of-an-sqlserver-database[^]
Best Regards
M.Mitwalli


创建到两个数据库的两个不同的连接,并对其进行查询.
create two different connections to the two databases, and query them both.


在这里,您可能必须查看一下自己的设计应用程序.
我从您的问题中了解到的是,您有客户端和服务器.
有一些数据将在客户端生成,并将同时存储在客户端数据库中.相同的数据将存储在服务器端数据库中.

在这里,您可以创建两个不同的连接字符串,一个用于本地数据库,一个用于远程数据库.并据此使用.
为了识别客户端,您可能需要传递一些唯一值(GUID),该值可以识别客户端以及存储在服务器数据库中的数据.创建一个额外的表,该表可以存储客户端ID,并将该数据行ID存储在服务器端存储的每个数据中.
Here you may have to look at the design of your application.
As what I have understood from your question is that, You have client and a server.
there are some data which will be generated at clientside and which will be stored in clientside database at the same time the same data will get stored at serverside database.

Here you can create two different connection string one for local database and one for remote database. and use accordingly.
And to identify client, you may need to pass some unique value(GUID) which can identify your client along with the data that you store in server database. Create one extra table which can store the client id and store that data row id in every data that you store at server side.


这篇关于在C#Windows应用程序中连接两个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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