اشکال در ذخیره عکس در دیتابیس بعد از rotate آن (#C)

homayon_azizi

New Member
سلام خدمت اساتید و دوستان محترم
خسته نباشید
نمیدونم چرا این برنامم ارور میده. من اگه رو دکمه مربوط به rotateرو نزنم ، عکسم تو دیتابیس ذخیره میشه ولی کافیه یه بار rotate کنم ، اونوقت خطای کامپایل میده ( vshost.exe )
این سورس مربوط به rotate :

کد:
if (pictureBox2.Image == null)
            {
                MessageBox.Show("لطفاٌ ابتدا عکس را انتخاب کنید", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                IMG1 = pictureBox2.Image;
                IMG1.RotateFlip(RotateFlipType.Rotate90FlipNone);
                pictureBox2.Image = IMG1;
            }

اینم سورس مربوط به ذخیرش تو دیتابیس :



کد:
myconnection a = new myconnection();
                            if (a.open())
                            {
                                dt.Clear();
                                MemoryStream ms = new MemoryStream();
                                pictureBox2.Image.Save(ms, pictureBox2.Image.RawFormat);
                                byte[] arrPic = ms.GetBuffer();
                                ms.Close();
                                a.com.CommandText = "select * from tb_receive_letter where id='" + txtnumber.Text + "' or codearchive='" + txtbaygani.Text + "'";
                                a.com.Connection = a.con;
                                a.da = new SqlDataAdapter(a.com);
                                a.da.Fill(dt);
                                if (dt.Rows.Count != 0)
                                {
                                    MessageBox.Show("شماره نامه یا کد بایگانی تکراری است", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                else
                                {
                                    if (MessageBox.Show("آیا از ثبت اطلاعات اطمینان دارید؟", "توجه", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                    {
                                        a.com.CommandText = "insert  into tb_receive_letter  (id,date,appendix,organization,statement,following   ,actions,back,type,description,signature,codearchi  ve,picorganization)  values ('" + txtnumber.Text + "','" + irDateTimePicker1.Text + "','" + txtpeyvast.Text + "','" + txtsazman.Text + "','" + txtsharh.Text + "','" + txtpeyro.Text + "','" + txteghdam.Text + "','" + txtbazgasht.Text + "','" + cmbnoe.Text + "','" + txttozih.Text + "','" + txtemza.Text + "','" + txtbaygani.Text + "',@picorganization)";
                                        a.com.Connection = a.con;
                                        a.com.Parameters.Add("@picorganization", SqlDbType.VarBinary).Value = arrPic;
                                        a.com.ExecuteNonQuery();
                                        MessageBox.Show("اطلاعات با موفقیت ثبت گردید", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        label8.Visible = false;
                                        radioButton1.Checked = false;
                                        radioButton2.Checked = false;
                                        txtbazgasht.Text = "";
                                        txtbaygani.Text = "";
                                        txtemail.Text = "";
                                        txteghdam.Text = "";
                                        txtnumber.Text = "";
                                        txtpeyvast.Text = "";
                                        txtpeyro.Text = "";
                                        txtsazman.Text = "";
                                        txtsharh.Text = "";
                                        txttozih.Text = "";
                                        cmbnoe.Text = "";
                                        txtemza.Text = "";
                                        pictureBox1.Image = null;
                                        pictureBox2.Image = null;
                                    }
                                }
                            }

من خودم این احتمال رو میدم که بعد از اینکه عکسمو rotate کردم مقدار picturebox ، هیچ ( null ) میشه.
تو رو خدا اگه میشه کمک کنید. مرسی
 

جدیدترین ارسال ها

بالا