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:
MySQL server version: 5.6.20
data
.NET Framework version: 4.5.1
MySQL Connector/Net 6.8.3
Different things:
Production OS: Windows Server 2012 R2 (with IIS 8.5)
Development OS: Windows 7 64 bit (with IIS 7.5)
Yes:
I have added Allow Zero Datetime=True and Convert Zero Datetime=True in the connection string.
Thanks for any help,
Solutions1
removing Allow Zero Datetime=True solved the problem.
Solutions2
Removing "Convert Zero Datetime=True" instead Allow Zero Datetime=True is worked for me..... try it
Talk1:
Thx, it works but someone can explain why it works?