Reputation: 549
I have this code running on development machine perfectly:
MySqlCommand cmd = new MySqlCommand("select * from orders where id=1", conn);
System.Data.DataTable dt = new System.Data.DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(dt);
But when I run the same code with same database on the prodcution server it throws this error:
[ArgumentException: Type of value has a mismatch with column type]
System.Data.Common.ObjectStorage.Set(Int32 recordNo, Object value) +2256750
System.Data.DataColumn.set_Item(Int32 record, Object value) +60
[ArgumentException: Type of value has a mismatch with column typeCouldn't store <1.1.0001 00:00:00> in myTimeColumn Column. Expected type is MySqlDateTime.]
System.Data.DataColumn.set_Item(Int32 record, Object value) +6632812
System.Data.DataTable.NewRecordFromArray(Object[] value) +6638777
System.Data.DataTable.LoadDataRow(Object[] values, Boolean fAcceptChanges) +111
System.Data.ProviderBase.SchemaMapping.LoadDataRow() +148
System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping) +141
System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) +292
System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) +657
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +368
System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +487
System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +293
Note: myTimeColumn is datetime in the table.
Same things of the development and production machine:
Different things:
Yes:
Thanks for any help,
Upvotes: 1
Views: 3247
Reputation: 404
Removing "Convert Zero Datetime=True" instead Allow Zero Datetime=True is worked for me..... try it
Upvotes: 2
Reputation: 549
removing Allow Zero Datetime=True
solved the problem.
Upvotes: 3