c# - Why my method is not updating -


i have 3 tables. have main table called employeemaintable

  fieldname    data type  * eid          text   firsname     text   surname      text 

second table called employeejobdetailstable

 fieldname      data type * ejobid        text   eid           text   jobdescrip    text 

third table called employeeappraisaldetails

   fieldname         datatype    eapprid           text    ejobid           text    goalsachieved     memo 

relationship employeemaintable can have many employeejobdetailstable , employeejobdetailstable can have many employeeappraisaldetails.

  1. i can create, update , delete records employeemaintable
  2. i can create, update , delete records employeejobdetailstable
  3. i can insert , delete records employeeappraisaldetails unable update.

here update method...

eappr class

 public static void aupdate(string goals, string eapprid)     {          var con = getconnection();         oledbcommand cmd = new oledbcommand();         cmd.commandtype = commandtype.text;         cmd.commandtext = (@"update [employeeappraisaldetails] set [goalsachieved] = ? [eapprid] = ?");         cmd.parameters.addwithvalue("@goalsachieved", goals);         cmd.parameters.addwithvalue("@eapprid", eapprid);         cmd.connection = con;         con.open();         cmd.executenonquery();         con.close();     } 

main class

private void btnupdateappr_click(object sender, eventargs e)     {         eappr.aupdate(cbapprscore.text, txtapprid.text);     } 

my question

what doing wrong? there no error think because employeeappraisaldetails not linked employeemaintable or doing wrong update method? idea have employeejobdetailstable many employeeappraisaldetails. 1 job title can have many appraisals.

huge thanks

update 1 did debug on executenonquery , got

string goals  === "test" string eapprid === "".  

update 2

changed data type goalsachieved memo text. have 2 records in employeeappraisaldetails. update latest record not previous record once. when close , restart application cannot update either of records

update 3 because using ms access 2003 , c#, have decided not use update parameter on occasion. it's not worth hassle when sql server should have been used.

addwithvalue not perfect, sending string value , parameter name. actual data type memo in access database. there can issue when mapping correct data type addwithvalue method. better give type , add parameters below

cmd.parameters.add("@goalsachieved", oledbtype.longvarwchar).value = goals; 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -