插入写入
代码:
SqlConnection sqlc = new SqlConnection(
"Data Source=" + Environment.MachineName + @"\SQLEXPRESS;" +
"Integrated security=true;" +
"database=someDB");
SqlCommand sqlcmd;
string tmp = string.Empty;
for(int i = 0; i < 100000; i++)
{
tmp += "inserto into [db].[Files](...) values (...);"
}
sqlcmd = new SqlCommand(tmp, sqlc);
try { sqlc.Open(); sqlcmd.ExecuteNonQuety(); } cathc{}
仅插入< 1000 次写入 如何写全部100000次写入?可能会销毁并创建 sqlcmd?
code :
SqlConnection sqlc = new SqlConnection(
"Data Source=" + Environment.MachineName + @"\SQLEXPRESS;" +
"Integrated security=true;" +
"database=someDB");
SqlCommand sqlcmd;
string tmp = string.Empty;
for(int i = 0; i < 100000; i++)
{
tmp += "inserto into [db].[Files](...) values (...);"
}
sqlcmd = new SqlCommand(tmp, sqlc);
try { sqlc.Open(); sqlcmd.ExecuteNonQuety(); } cathc{}
inserted only < 1000 writes
How write all 100000 writes ?? May be destroy and create sqlcmd?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能应该将命令分成更小的命令。假设每个 SqlCommand 插入 500 条记录,直到插入所有记录为止。
You should probably split the commands up into smaller commands. Say, inserting 500 records per SqlCommand until you've inserted all your records.