.net - c# how to update data with photo looking for some help to understand :'( -


hi guys how can update data photo without error database name table , table content is

  • id,
  • firstname,
  • middlename,
  • lastname,
  • gender,
  • address,
  • dateofbirth,
  • placeofbirth,
  • fathersname,
  • fathersoccupation,
  • mothersname,
  • mothersoccupation,
  • guardian,
  • relation,
  • guardianoccupation,
  • image,

i edit data appear when changed/edit how can troubleshoot this:

enter image description here

private void button3_click(object sender, eventargs e) {     byte[] images = null;     filestream fs = new filestream(img, filemode.open, fileaccess.read);     binaryreader br = new binaryreader(fs);     images = br.readbytes((int)fs.length);      con.open();      string sql = "update table1 set id=@id,firstname=@firstname,middlename=@middlename,lastname=@lastname,gender=@gender,dateofbirth=@dateofbirth,placeofbirth=@placeofbirth,address=@address,fathersname=@fathersname,fathersoccupation=@fathersoccupation,mothersname=@mothersname,mothersoccupation=@mothersoccupation,guardian=@guardian,relation=@relation,guardianoccupation=@guardianoccupation,@images=images id=@id";      cmd = new sqlcommand(sql, con);     cmd.parameters.add(new sqlparameter("@id", textbox1.text));     cmd.parameters.add(new sqlparameter("@firstname", textbox2.text));     cmd.parameters.add(new sqlparameter("@middlename", textbox3.text));     cmd.parameters.add(new sqlparameter("@lastname", textbox4.text));     cmd.parameters.add(new sqlparameter("@gender", combobox1.text));     cmd.parameters.add(new sqlparameter("@dateofbirth", datetimepicker1.value.tostring()));     cmd.parameters.add(new sqlparameter("@placeofbirth", textbox5.text));     cmd.parameters.add(new sqlparameter("@address", textbox6.text));     cmd.parameters.add(new sqlparameter("@fathersname", textbox7.text));     cmd.parameters.add(new sqlparameter("@fathersoccupation", textbox8.text));     cmd.parameters.add(new sqlparameter("@mothersname", textbox9.text));     cmd.parameters.add(new sqlparameter("@mothersoccupation", textbox10.text));     cmd.parameters.add(new sqlparameter("@guardian", textbox11.text));     cmd.parameters.add(new sqlparameter("@relation", textbox12.text));     cmd.parameters.add(new sqlparameter("@guardianoccupation", textbox13.text));     cmd.parameters.add(new sqlparameter("@images", images));      int n = cmd.executenonquery();     con.close();      viewlist();     messagebox.show(n.tostring() + "update successfull"); } 

the second error when didnt browse , display photo:

the second error when didnt browse , display photo

your update statement incorrect! trying assign column parameter.. (@images=images)

string sql = "update table1 set id=@id,firstname=@firstname,middlename=@middlename,lastname=@lastname,gender=@gender,dateofbirth=@dateofbirth,placeofbirth=@placeofbirth,address=@address,fathersname=@fathersname,fathersoccupation=@fathersoccupation,mothersname=@mothersname,mothersoccupation=@mothersoccupation,guardian=@guardian,relation=@relation,guardianoccupation=@guardianoccupation,@images=images id=@id"; 

try this:

string sql = "update table1 set id=@id,firstname=@firstname,middlename=@middlename,lastname=@lastname,gender=@gender,dateofbirth=@dateofbirth,placeofbirth=@placeofbirth,address=@address,fathersname=@fathersname,fathersoccupation=@fathersoccupation,mothersname=@mothersname,mothersoccupation=@mothersoccupation,guardian=@guardian,relation=@relation,guardianoccupation=@guardianoccupation,image=@images id=@id"; 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -