I've searched around for a while and can't seem to find out how/where I set the timeout on a bulk insert task programmatically. Here is a snippet of code that works as long as the input file is pretty small....when I attempted to pump 1.3 million rows through the default timeout value was not big enough and a timeout exception occurred.
Package loadPackage = new Package();
Stopwatch timer = new Stopwatch();
timer.Start();
ConnectionManager conMgr = loadPackage.Connections.Add("FLATFILE");
conMgr.ConnectionString = @"C:\BWR.txt";
conMgr.Name = "FileInput";
conMgr = loadPackage.Connections.Add("ADO.NET:ODBC");
conMgr.ConnectionString = @"Data Source=FOO;Initial Catalog=DestinationDb;Integrated Security=True;";
conMgr.Name = "DestinationDB";
TaskHost task = loadPackage.Executables.Add("STOCK:BulkInsertTask") as TaskHost;
BulkInsertTask biTask = (BulkInsertTask)task.InnerObject;
biTask.UseFormatFile = true;
biTask.FormatFile = @"C:\BWR_1.fmt";
biTask.SourceConnection = "FileInput";
biTask.DestinationConnection = "DestinationDB";
biTask.DestinationTableName = "StageBWR";
biTask.BatchSize = 100;
DTSExecResult result = loadPackage.Execute();
timer.Stop();
Console.WriteLine(string.Concat("Process took(ms): ", timer.ElapsedMilliseconds.ToString()));
Console.WriteLine(result.ToString());
if (loadPackage.Errors.Count > 0)
{
foreach (DtsError error in loadPackage.Errors)
{
Console.WriteLine(error.Description);
}
}
Again, the code above works just fine until we hit a timeout. There is no Timeout property on the BulkInsertTask class, nor can I see a way to set it on the Sql Connection. I don't even see them in the Connectionmanager.Properties collection for either the file connection or the database connection.
Am I overlooking the obvious somewhere