private void button5_Click(object sender, EventArgs e)
{
string filepath = textBox2.Text;
string connectionString_i = string.Format(@"Provider=Microsoft.Jet.OleDb.4.0; Data Source={0};Extended Properties=""Text;HDR=YES;FMT=Delimited""",
Path.GetDirectoryName(filepath));
using (OleDbConnection connection_i = new OleDbConnection(connectionString_i))
{
connection_i.Open();
OleDbCommand command = new OleDbCommand("Select * FROM [" + Path.GetFileName(filepath) +"]", connection_i);
using (OleDbDataReader dr = command.ExecuteReader())
{
string sqlConnectionString = MyConString;
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
{
SqlBulkCopy bulkInsert = new SqlBulkCopy(sqlConnectionString);
bulkInsert.DestinationTableName = "Table in SQL DB";
bulkInsert.WriteToServer(dr);
MessageBox.Show("Upload to DB Successful!");
}
}
connection_i.Close();
}
}
现在我想读取包含大数据的文件并插入到SQL表中。问题是SQL连接超时只有30秒。 我想将SQL连接的超时时间增加到大约2或3分钟。
我该怎么做..请帮忙。 我将数据从csv文件上传到SQL db。
感谢。