I'm trying to insert a massive amount of data into my database using SqlBulkCopy. I originally built this program using .NET 4.5 but it won't run on the older machine I need it to run on. During testing (with 4.5) the program worked flawlessly however when I downgraded to .NET 4.0 it no longer works.
Here is the code:
string query = string.Format("Generic database query text");
OdbcCommand com = new OdbcCommand(query, conn);
OdbcDataReader reader = com.ExecuteReader();
//insert the new records
SqlBulkCopy sbc = new SqlBulkCopy(connectionString);
sbc.EnableStreaming = true;
sbc.BulkCopyTimeout = 1200;
sbc.DestinationTableName = "TableName;
sbc.WriteToServer(reader);
In .NET 4.5 I can enable streaming while in .NET 4.0 I cannot. Disabling streaming in .NET 4.5 does NOT break the solution. This is the only difference between the code. The columns in the table are mapped exactly 100000% 1:1. Matching column names, matching data types, matching everything. I've also tried manually mapping the columns using the code below, to no avail.
sbc.ColumnMappings.add("column1", "matchedColumn1");
The exact error I'm getting is:
Arithmetic operation resulted in an overflow.
But I know there are no large numbers being churned. There is no math happening at all. It's a simple query from one and insert into another. I'm working with a small subset right now (for testing) where the IDs don't go above 5 digits and I've even tested changing all ints in the database to bigint. Didn't work.
Columns:
1 - Int
A1 -Varchar(50)
19 -Varchar(50)
True -bit
5/5/2011 -date
Passed InstaMed Standard Edits -text
1 -int
C0200000000000000023 -varchar(100)
39 -int
82 -int
Anyone have any ideas??