0
代碼:插入寫道
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寫入 怎麼寫都寫10萬?可能會破壞並創建sqlcmd?
plase寫代碼,「病因尚未明瞭 – 4iNo 2010-10-19 05:50:53
或者更好的辦法是優化SQL不要做100000個陳述。也許一個存儲過程也可能是一個更好的選擇? – RPM1984 2010-10-19 05:55:03
並且作爲參數傳遞? – 4iNo 2010-10-19 06:03:29