如何使用C#将数据从一个服务器数据库表插入到其他服务器数据库表 [英] How to insert data from one server database table to other server database table using C#

查看:67
本文介绍了如何使用C#将数据从一个服务器数据库表插入到其他服务器数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How to insert data from one server database table to other server database table using c#



例如,我有两个SQL服务器A和B我想创建一个服务,它将数据从一个服务器dB插入到其他服务器dB表。请帮我解决这个问题很紧急。



我尝试了什么:



两个服务器A和B

。数据表a =数据表B


For example I have two SQL server A and B. I want to create one service which will insert data from one server dB to other server dB table. Please help me on this it's urgent.

What I have tried:

Two server A and B
.Data table a = data table B

推荐答案

每个数据库需要两个数据连接。打开第一个并提取数据。关闭它并打开第二个连接并进行更新
You need two data connections one for each db. Open the first and pull your data. close it and open the second connection and do your update


如果是SQL Server ...



您可以使用< a href =https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy(v=vs.110).aspx> SqlBulkCopy类(System.Data.SqlClient) [ ^ ]



详情请见: ADO.NET中的SQL Server数据操作Microsoft Docs [ ^ ]
If it's an SQL Server...

You can use SqlBulkCopy Class (System.Data.SqlClient)[^]

For further details, please see: SQL Server Data Operations in ADO.NET | Microsoft Docs[^]


这篇关于如何使用C#将数据从一个服务器数据库表插入到其他服务器数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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