November 9, 2009 at 5:15 am
Hi
I'm stumped by the following exception message:
Received an invalid column length from the bcp client for colid 19.
The last column in the DataTable which I'm trying to update via
using (SqlConnection con = db.CreateConnection() as SqlConnection)
{
con.Open();
SqlBulkCopy bulk = new SqlBulkCopy(con);
bulk.MapColumnsFromData(dataSet.Tables[0]);
//do the insert
bulk.DestinationTableName = tableName;
bulk.WriteToServer(dataSet.Tables[0]);
}
Now the last column is defined as a smallint in the database and I'm using this line to specify this fact:
submitResultData.Tables[0].Columns.Add("AppointmentCode", typeof(string));
submitResultData.Tables[0].Columns.Add("DeductionType", typeof(Int16));
Now I thought that maybe Int16 and smallint aren't compatible,
so I removed the last column
// submitResultData.Tables[0].Columns.Add("DeductionType", typeof(Int16));
and tried it just for the first 18 columns and then this appeared!!!
Received an invalid column length from the bcp client for colid 18.
however the last column now contains a string but still it is complaining about some invalid column length,
why? any ideas?
October 19, 2010 at 3:35 pm
Look at this article and see if it helps:
http://www.csvreader.com/posts/validating_datareader.php
When I ran into this I found out that one of the values was greater in length then the max allowed. In other words Max in my table was 50 chars and bcp was trying insert 52 etc
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply