c# - data type mismatch in criteria expression, error persist even when the code is perfect -


this code have made update table doctorss. code has no errors , have made sure table data types ok; doctor_id data type put autonumber , others short text.

further know code have impact on sql injections, , should use parameters this, way possible , there's error cannot solve, need know solution error when update table.

error:

data type mismatch in criteria expression

i using access 2013 , visual studio 2013.

  private void button6_click(object sender, eventargs e)     {         try         {              oledbconnection cone = new oledbconnection("provider=microsoft.ace.oledb.12.0;data source=e:\\dev\\assignt_soft\\healthline_\\healthline_\\healthline_db.accdb");             oledbcommand come = new oledbcommand("update doctorss set  doctor_name='"+textbox3.text+"', dspecial='"+combobox4.text+"', dday= '"+combobox3.text+"',  dtime= '"+textbox2.text+"' doctor_id='" + textbox4.text+"';");             come.connection = cone;             cone.open();             come.executenonquery();             cone.close();             messagebox.show("doctor updated");              oledbconnection cont = new oledbconnection("provider=microsoft.ace.oledb.12.0;data source=e:\\dev\\assignt_soft\\healthline_\\healthline_\\healthline_db.accdb");             oledbcommand comt = new oledbcommand("select * doctorss", cont);             datatable dte = new datatable();             cont.open();             dte.load(comt.executereader());             datagridview1.datasource = dte;             cont.close();              return;          }          catch (oledbexception expee)         { messagebox.show(expee.message); }     } 

i have made sure table data types ok

since doctor_id autonumber should not use quotes

     oledbcommand come = new oledbcommand("update doctorss set                                doctor_name='"+textbox3.text+"',                               dspecial='"+combobox4.text+"',                              dday= '"+combobox3.text+"',                                dtime= '"+textbox2.text+"'                               doctor_id=" + textbox4.text+";"); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -