All,
I have the following BulkCopy
operation:
// Convert the FlexGrid to a DataTable.
DataTable currData = (DataTable)c1ErrFlexGrid.DataSource;
// Insert the data into the database.
SqlBulkCopy SqlBulkIns = new SqlBulkCopy(strConnString, SqlBulkCopyOptions.Default);
SqlBulkIns.BatchSize = 5000;
SqlBulkIns.DestinationTableName = String.Format("dbo.{0}", strTableName);
SqlBulkIns.WriteToServer(currData);
where strConnectionString
is a defined and valid connection string. This has worked fine in the past when the table strTableName
exists and the fields are defined. I now wish to perform this BulkCopy
operation on a DataTable
that is defined at run-time; that is, without predefining the table structure in SQL. Is this possible? If so, how?
Thanks for your time.
您可以使用此SqlTableCreator对象从数据表创建SQL表,然后运行批量插入。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.