C# Access OleDb Data type mismatch in criteria expression -
would please kindly check following code errors give me 'data type mismatch in criteria expression' exception? can't seem find source of problem...

*record.date of nullable datetime? type explicitly casted datetime
*record.date set nullable other uses in program. record.date set insert operation retrieved datetimepicker, record.date value method should never null.
where

and (in case you're wondering)

from access file (design view):

thank you!
here's addrecord method. thanks!
public static int addrecord(record record) { oledbconnection connection = labmeetingrecordsdb.getconnection(); string insertstatement = "insert documentinfo " + "([filename], [date], [subject], [type]) " + "values (?, ?, ?, ?)"; try { oledbcommand insertcommand = new oledbcommand(insertstatement, connection); insertcommand.parameters.addwithvalue("@filename", record.filename); insertcommand.parameters.addwithvalue("@date", (datetime)record.date); insertcommand.parameters.addwithvalue("@subject", record.subject); insertcommand.parameters.addwithvalue("@type", record.getdbtype()); connection.open(); insertcommand.executenonquery(); string selectstatement = "select ident_current('documentinfo') documentinfo"; oledbcommand selectcommand = new oledbcommand(selectstatement, connection); int recordid = convert.toint32(selectcommand.executescalar()); addcategory(connection, recordid, record.category); return recordid; } catch (oledbexception ex) { throw ex; } { connection.close(); } }
so...[problem solved] :d
from here learnt that
the problem of mismatch in criteria expression due oledbtype assigned parameter used represent datetime.now value when call addwithvalue.
the oledbtype choosen addwithvalue dbtimestamp, access wants oledbtype.date.
meaning convenient addwithvalue pulled fast 1 on me...
thank @larstech , @djkraze helping me out despite confusion of presentation!
Comments
Post a Comment