I am trying to insert rows from an excel file into sql server 2000 using bulkcopy. In the table there is a 'rowguid' field and its default value is set to (newid()) and cannot except null values. Also RowGUID is set to "Yes".
In my code i remove the column mapping for rowguid . Here is my code.
if (dr.HasRows)
{
using (SqlBulkCopy bulkCopy =
new SqlBulkCopy(sqlConnectionString))
{
bulkCopy.DestinationTableName = "configtest";
SqlBulkCopyColumnMapping value = new SqlBulkCopyColumnMapping("rowguid", "rowguid");
bulkCopy.ColumnMappings.Remove(value);
bulkCopy.WriteToServer(dr);
}
}
I get column 'rowguid does not allow dbnull.value
definition for that field is : rowguid , uniqueidentifier, allow nulls unticked.