【发布时间】:2010-10-09 08:24:22
【问题描述】:
我不确定我是否得到了关于 API 使用的正确定义。我有一段代码用于从 c# 应用程序将 BulkInsert 插入 SQL。它说 sn-p 显示了 API 使用情况。怎么翻译?
private void WriteToDatabase()
{
// get your connection string
string connString = "";
// connect to SQL
using (SqlConnection connection =
new SqlConnection(connString))
{
// make sure to enable triggers
// more on triggers in next post
SqlBulkCopy bulkCopy =
new SqlBulkCopy
(
connection,
SqlBulkCopyOptions.TableLock |
SqlBulkCopyOptions.FireTriggers |
SqlBulkCopyOptions.UseInternalTransaction,
null
);
// set the destination table name
bulkCopy.DestinationTableName = this.tableName;
connection.Open();
// write the data in the "dataTable"
bulkCopy.WriteToServer(dataTable);
connection.Close();
}
// reset
this.dataTable.Clear();
this.recordCount = 0;
}
【问题讨论】:
-
在本例中,您正在使用 Sql Api 访问数据库。 System.Data.SqlClient 中的 SqlConnection、SqlBulkCopy 等是“Sql”API 的一部分
标签: c# .net asp.net sql-server