c# - SqlBulkCopy Converting string to datetime with US Format -


I am transferring an application database from an unknown source (can be a CSV / SQL server), as I do not know where the data is coming from, I first have a holding table of data (all column ), Then I consider the value in the test column what it should be and importing the database or flagging the data error.

To transfer the data, If I am loading into C #, then use SqlBulkCopy to insert the data in the holding table. It's all working, but I'm having a problem with the Data Time column. In the C # datatable, the date value is in the YMD format and stored as a string, the column in column is a varchar (255) in the holing table, but at some point the transfer process is being converted to DMY format, making it one When I try to validate the dates in the Holding Table.

I do this to load the datatable:

  cmd.CommandText = string.Format ("SET DATEFORMAT YMD; {0}", CMD. Commands) ; SqlDataAdapter Data Editor = New SQL DataAdapter (CMD); DataTable ReturnTable = New DataTable (); DataAdapter.Fill (returnTable);  

What data do I transfer:

 using  (SqlBulkCopy bulkCopy = new SqlBulkCopy (DBContext.ConnectionString, SqlBulkCopyOptions.KeepNulls)) {bulkCopy .DestinationTableName = "HoldingTable"; Wholesaler Batch size = 10000; {BulkCopy.ColumnMappings.Add (im.MappingColumn, imTableField.FieldName); Foreach (i.IsImported) ImportMapping.Where (i = & gt; impMap im); } Foreach (Column Mapping in SqlBulkCopy columnmapping) {bulkCopy.ColumnMappings.Add (m); } BulkCopy.WriteToServer (DataDataTable); }  


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -