I use this code to send sql request:
SqlBulkCopy bulkCopy = new SqlBulkCopy(Connection);
foreach (DataColumn column in dt.Columns)
{
bulkCopy.ColumnMappings.Add(column.ColumnName, column.ColumnName);
}
bulkCopy.DestinationTableName = "nsi." + classifierData.Info.TableName;
bulkCopy.WriteToServer(dt);
and get an exception : "Received an invalid column length from the bcp client for colid". How can I find an row number with error data?
I've tried to use this, but it does'nt work (values are always the same):
FieldInfo currentRow = typeof(SqlBulkCopy).GetField("_currentRowLength", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
var currentRowNumber = currentRow.GetValue(bulkCopy);
FieldInfo _rowsCopiedField = typeof(SqlBulkCopy).GetField("_rowsCopied", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
var currentRowN = _rowsCopiedField.GetValue(bulkCopy);
Aucun commentaire:
Enregistrer un commentaire