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...

enter image description here

*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

enter image description here

and (in case you're wondering)

enter image description here


from access file (design view):

enter image description here


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

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -