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();
}
}
Now I want to read file with large data and insert into SQL Table. the problem is that SQL connetion timeout is just 30 seconds. I want to increase timeout of SQL connection to about 2 or 3 minutes.
How do I do that.. Please help. I am uploading data from a csv file to SQL db.
Thanks.