Dear guys
I insert data from a typed dataset into my MSSQL database by using SqlBuldCopy class:
foreach (DataTable dt in ds.Tables)
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(conn))
{
bulkCopy.DestinationTableName = "dbo." + dt.TableName + "_neu";
try
{
bulkCopy.WriteToServer(dt);
}
catch (Exception ex)
{
throw new FaultException("\n" + dt.TableName + ": " + ex.Message);
}
}
}
It works great. But when I insert DataTime.MinValue into my database i get this error: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. Is there a way to say in the foreach something like this: if DateTime field value from dataset is DateTime.MinValue, don't insert the DateTime field from dataset into my database?
Best regards