jeudi 22 septembre 2016

given value of type String from the data source cannot be converted to type datetime of the specified target column

Please need your help in urgent.

facing the issue 'The given value of type String from the data source cannot be converted to type datetime of the specified target column while inserting data into database using sqlbulkcopy.' only in one server, for other server and also in my dev environment everything working fine.

   using (SqlBulkCopy sbc = new SqlBulkCopy(DbSqlConn))
                       {
                           DbSqlConn.Open();

                           // inserting data into table IT000
                           sbc.DestinationTableName = strschema + StoredProcedureNames.UPLOADTABLEGENERICHRIT000;

                           // Number of records to be processed in one go
                           sbc.BatchSize = tblUploadData.Rows.Count;


                           sbc.ColumnMappings.Add("txtEmployeeNo", "txtEmployeeNo");
                           sbc.ColumnMappings.Add("txtCompany", "txtCompany");
                           sbc.ColumnMappings.Add("txtEmpTypeCode", "txtEmpTypeCode");
                           sbc.ColumnMappings.Add("intProcessId", "intProcessId");
                           sbc.ColumnMappings.Add("txtBatchID", "txtBatchID");
                           sbc.ColumnMappings.Add("intUploadType", "intUploadType");

                           sbc.ColumnMappings.Add("intSubTypeSAP", "intSubTypeSAP");
                           sbc.ColumnMappings.Add("txtReasonSAPCode", "txtReasonCode");
                           sbc.ColumnMappings.Add("txtReasonSAPCode", "txtReasonSAPCode");

                          // sbc.ColumnMappings.Add("txtEmployeeSubGroup", "txtEmployeeSubGroup");

                           sbc.ColumnMappings.Add("dtStartDate", "dtStartDate");
                           sbc.ColumnMappings.Add("txtCreatedBy", "txtCreatedBy");
                           sbc.ColumnMappings.Add("dtCreatedDate", "dtCreatedDate");
                           sbc.ColumnMappings.Add("dtLastModifiedDate", "dtLastModifiedDate");
                           sbc.ColumnMappings.Add("txtLastModifiedBy", "txtLastModifiedBy");

                           sbc.ColumnMappings.Add("flgInfoTypeEvent", "flgInfoTypeEvent");
                           sbc.ColumnMappings.Add("txtReferenceKey", "txtReferenceKey");
                           sbc.ColumnMappings.Add("flgstatus", "flgstatus");
                           sbc.ColumnMappings.Add("txtRemarks", "txtRemarks");
                           sbc.ColumnMappings.Add("flgModified", "flgModified");
                           sbc.WriteToServer(tblUploadData);
                           intRes = 1;
                           sbc.Close();
                           DbSqlConn.Close();

                       }

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire