且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将Excel工作表数据保存到SQL Server表.

更新时间:2023-09-13 15:45:40

) 使用( var myConnection = OleDbConnection( _Provider)) 使用( var destinationConnection = 系统. Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager. ConnectionStrings [" ].ConnectionString))// 数据库连接字符串 使用( var bulkCopy = 系统. Data.SqlClient.SqlBulkCopy(System.Configuration.ConfigurationManager. ConnectionStrings [" ].ConnectionString))// 数据库连接字符串 { 字符串 table = " ; bulkCopy.DestinationTableName = table; // SQL Server上的目标表名称. 使用( var myCommand = OleDbCommand( _Query,myConnection)) { myConnection.Open(); destinationConnection.Open(); var myReader = myCommand.ExecuteReader(); bulkCopy.WriteToServer(myReader); } } }
) using (var myConnection = new OleDbConnection(_Provider)) using (var destinationConnection = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager. ConnectionStrings["superConnection"].ConnectionString))//Database Connection String using (var bulkCopy = new System.Data.SqlClient.SqlBulkCopy(System.Configuration.ConfigurationManager. ConnectionStrings["superConnection"].ConnectionString))//Database Connection String { string table = "orders"; bulkCopy.DestinationTableName = table;//Destination Table name on the SQL Server. using (var myCommand = new OleDbCommand(_Query, myConnection)) { myConnection.Open(); destinationConnection.Open(); var myReader = myCommand.ExecuteReader(); bulkCopy.WriteToServer(myReader); } } }


你好

我想SQL不会同意存储用作定界符的字符..我不使用Microsoft SQL,但确实将二进制数据存储在SQLite数据库中,并且仅对BLOB字段有效....

MTC

蒂埃里(Thierry)
Hello

I guess SQL won''t agree to store characters that it uses as delimiters.. I do not use Microsoft SQL but I do store binary data in a SQLite database and it works fine only for BLOB fields...

MTC

Thierry