value cannot be null. parameter name encoder MySql C# -


i using 2 separate buttons rotate image , save image. somehow rotation working. save(update) not working. tried find problem, couldn't.

the error "value cannot null. parameter name encoder". best guess rotateflip somehow effecting picture box.

regards

this code,

private void btnrotate_click(object sender, eventargs e)         {              if (pictureboxprofile.image != null)             {                 pictureboxprofile.image.rotateflip(rotatefliptype.rotate90flipnone);                 pictureboxprofile.refresh();             }             else             {                 messagebox.show("select image");             }         }   private void btnsave_click(object sender, eventargs e)         {             if (txtshortname.text == "" || txtphonenumberm.text == "" || txtfullname.text == "" || gender.text == "" || richtextboxaddress.text == "" || txtphonenumberh.text == "" || status.text == "" || pictureboxprofile.image == null)             {                 messagebox.show("empty fields detected!. please fill fields");                 return;             }              try             {                  con.open();                                  mysqlcommand cmd2 = new mysqlcommand("update customer set mr_mrs = @mr_mrs, short_name = @short_name, full_name = @full_name, nic_number = @nic_number, gender = @gender, address = @address, phone_no_home = @phone_no_home, phone_no_mobile = @phone_no_mobile, image = @image, status = @status, type = @type, nic_frnt = @nic_frnt, nic_back = @nic_back (nic_number=@nic_number)", con);                  memorystream ms = new memorystream();                 pictureboxprofile.image.save(ms, pictureboxprofile.image.rawformat);                 byte[] img = ms.toarray();                  memorystream ms2 = new memorystream();                 picturebox1.image.save(ms2, picturebox1.image.rawformat);                 byte[] img2 = ms2.toarray();                  memorystream ms3 = new memorystream();                 picturebox3.image.save(ms3, picturebox3.image.rawformat);                 byte[] img3 = ms3.toarray();                  cmd2.parameters.addwithvalue("@mr_mrs", mr_mrs.text);                 cmd2.parameters.addwithvalue("@short_name", txtshortname.text);                 cmd2.parameters.addwithvalue("@full_name", txtfullname.text);                 cmd2.parameters.addwithvalue("@nic_number", textbox1.text);                 cmd2.parameters.addwithvalue("@gender", gender.text);                 cmd2.parameters.addwithvalue("@address", richtextboxaddress.text);                 cmd2.parameters.addwithvalue("@phone_no_home", txtphonenumberh.text);                 cmd2.parameters.addwithvalue("@phone_no_mobile", txtphonenumberm.text);                 cmd2.parameters.addwithvalue("@status", status.text);                 cmd2.parameters.addwithvalue("@image", img);                 cmd2.parameters.addwithvalue("@type", combobox1.text);                 cmd2.parameters.addwithvalue("@nic_frnt", img2);                 cmd2.parameters.addwithvalue("@nic_back", img3);                 cmd2.executenonquery();                 messagebox.show(this, "customer updated succesfully!", "success", messageboxbuttons.ok, messageboxicon.information);                 this.close();                 con.close();                 cleardata();             }             catch (mysqlexception x)             {                 messagebox.show(x.message);                 con.close();             }         } 

the problem image.save method. instead of:

picturebox1.image.save(ms, picturebox1.image.rawformat); 

try this:

picturebox1.image.save(ms, imageformat.jpeg); 

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