c# - "Unable to convert MySQL date/time value to System.DateTime" on a query that does not even have DateTime -
i have downgraded mysql version version 5.5 , came across error. query trying run program.
set transaction isolation level read uncommitted; select * campaignparameters campaignid=225 limit 1; commit;
and error:
unable convert mysql date/time value system.datetime
as see, don't have datetime
in query.
the query works when run directly in mysql generates above error when execute inside c# program.
apparently, solution add convert 0 datetime=true
. there way set value in our mysql instead of adding value connection string?
update:
campaign parameters table
code:
public string getcampaignparameters(long campaignid) { dataset ds = new dataset(); string sql = string.format(@"set transaction isolation level read uncommitted; select * campaignparameters campaignid={0} limit 1; commit;", campaignid); try { using (mysqlconnection conn = new mysqlconnection(connectionstring)) { mysqldataadapter da = new mysqldataadapter(sql, conn); conn.open(); da.fill(ds); conn.close(); } if (ds == null || ds.tables == null || ds.tables[0].rows == null || ds.tables[0].rows.count == 0) return "empty"; else return ds.tables[0].rows[0]["params"].tostring(); } catch (exception ex) { console.writeline(ex.message); return "error"; } }
Comments
Post a Comment