I have 1 table in an Oracle database and another table in a SqlCe database. Both tables are called the same and I would like to transfer all the content of table in SqlCe database to the same table in Oracle database using SqlBulkCopy available in .NET Framework.
Oracle数据库中有一个表,SqlCe数据库中有一个表。这两个表都被调用相同,我希望使用. net Framework中可用的SqlBulkCopy将SqlCe数据库中的所有表内容转移到Oracle数据库中的同一个表中。
I know that using SqlBulkCopy it is possible to transfer any data from any source into a Sql database but I am not sure if it is possible from Sql database (in my case, SqlCe) to any source, for example, from SqlCe to Oracle. Could someone confirm me if it is possible?
我知道使用SqlBulkCopy可以将任何数据源中的任何数据传输到Sql数据库中,但是我不确定是否可以从Sql数据库(在我的例子中是SqlCe)传输到任何源,例如从SqlCe传输到Oracle。如果可能的话,谁能确认一下吗?
1 个解决方案
#1
2
You wouldn't use SqlBulkCopy
, as that is tied to SQL Server's connection protocol (TDS); however, since the target is oracle, OracleBulkCopy
should work fine. You would simply use ExecuteReader
on the SqlCe source, and feed that in:
您不会使用SqlBulkCopy,因为它与SQL Server的连接协议(TDS)绑定;然而,由于目标是oracle, OracleBulkCopy应该可以正常工作。您只需在SqlCe源上使用ExecuteReader,并将其输入:
using(var target = new OracleBulkCopy(oracleConnectionString))
using(var source = cecmd.ExecuteReader()) {
target.DestinationTableName = "Foo";
target.WriteToServer(source);
}
http://docs.oracle.com/html/E10927_01/OracleBulkCopyClass.htm
http://docs.oracle.com/html/E10927_01/OracleBulkCopyClass.htm
#1
2
You wouldn't use SqlBulkCopy
, as that is tied to SQL Server's connection protocol (TDS); however, since the target is oracle, OracleBulkCopy
should work fine. You would simply use ExecuteReader
on the SqlCe source, and feed that in:
您不会使用SqlBulkCopy,因为它与SQL Server的连接协议(TDS)绑定;然而,由于目标是oracle, OracleBulkCopy应该可以正常工作。您只需在SqlCe源上使用ExecuteReader,并将其输入:
using(var target = new OracleBulkCopy(oracleConnectionString))
using(var source = cecmd.ExecuteReader()) {
target.DestinationTableName = "Foo";
target.WriteToServer(source);
}
http://docs.oracle.com/html/E10927_01/OracleBulkCopyClass.htm
http://docs.oracle.com/html/E10927_01/OracleBulkCopyClass.htm