OdbcDataReader
-
Hi, I am fighting with SQL syntax. My database is MDB file, all reading work fine except DateTime columns. this code: string cmdR = "select M_TEMP from MEASUREMENT where M_TIME = '2007-11-16 13:10:00'"; using (OdbcCommand catCMD = new OdbcCommand(cmdR, mConn))¨ OdbcDataReader myReader = catCMD.ExecuteReader(); ... give me exception (ExecuteReader()): System.Data.Odbc.OdbcException with error: Data type mismatch in criteria expression. I tried various combination, for 'M_TIME = #'2007-11-16 13:10:00'# then error was: Syntax error in date in query expression 'M_TIME = #'2007-11-16 13:10:00'#' The closest probably was 'M_TIME = #2007-11-16 13:10:00# there were no exception but it select the first item except the one from the requsted time and i am still not able to find the way to insert time in correct way. Thank you for help to undertand this Viliam
viliam
-
Hi, I am fighting with SQL syntax. My database is MDB file, all reading work fine except DateTime columns. this code: string cmdR = "select M_TEMP from MEASUREMENT where M_TIME = '2007-11-16 13:10:00'"; using (OdbcCommand catCMD = new OdbcCommand(cmdR, mConn))¨ OdbcDataReader myReader = catCMD.ExecuteReader(); ... give me exception (ExecuteReader()): System.Data.Odbc.OdbcException with error: Data type mismatch in criteria expression. I tried various combination, for 'M_TIME = #'2007-11-16 13:10:00'# then error was: Syntax error in date in query expression 'M_TIME = #'2007-11-16 13:10:00'#' The closest probably was 'M_TIME = #2007-11-16 13:10:00# there were no exception but it select the first item except the one from the requsted time and i am still not able to find the way to insert time in correct way. Thank you for help to undertand this Viliam
viliam
Looking at this[^] you may find that
string cmdR = "select M_TEMP from MEASUREMENT where M_TIME = ts'2007-11-16 13:10:00'";
using (OdbcCommand catCMD = new OdbcCommand(cmdR, mConn))
{
OdbcDataReader myReader = catCMD.ExecuteReader();
...
}may work - I don't know for sure, (I don't use ODBCas my DBs are mySQL) Oh, and the convention for database access seems to be:
string cmdR = "SELECT field FROM table WHERE field = value";
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
Looking at this[^] you may find that
string cmdR = "select M_TEMP from MEASUREMENT where M_TIME = ts'2007-11-16 13:10:00'";
using (OdbcCommand catCMD = new OdbcCommand(cmdR, mConn))
{
OdbcDataReader myReader = catCMD.ExecuteReader();
...
}may work - I don't know for sure, (I don't use ODBCas my DBs are mySQL) Oh, and the convention for database access seems to be:
string cmdR = "SELECT field FROM table WHERE field = value";
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones