I want to save multiple Images now when I save all the 2 images I get no exception... but when I try to save only 1 or 2 or its throws an exception "Empty Path is not legal". my code is here
What I have tried:
byte[] img = null;
FileStream fs = new FileStream(imgloc, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
img = br.ReadBytes((int)fs.Length);
byte[] img1 = null;
FileStream fs1 = new FileStream(imgloc1, FileMode.Open, FileAccess.Read);
BinaryReader br1 = new BinaryReader(fs1);
img1 = br1.ReadBytes((int)fs1.Length);
con.Open();
SqlCommand cmd1 = new SqlCommand("insert into easypaisa (trid,selectopt,smobile,rmobile,snic,rnic,tamount,tcharges,totalcharges,date,descr,inv_no,Company,user_name,sprof,dataimg,image2) values ('" + textBox1.Text + "','" + comboBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + dateTimePicker1.Value.ToString("MM-dd-yyyy") + "','" + textBox10.Text + "','" + textBox9.Text + "','" + comboBox2.Text + "','" + Get_User_label.Text + "','" + textBox13.Text + "',@dataimg,@image2)", con);
cmd1.Parameters.Add(new SqlParameter("@dataimg", img));
cmd1.Parameters.Add(new SqlParameter("@image2", img1));
cmd1.ExecuteNonQuery();
con.Close();
MessageBox.Show("Data Saved successfully", "Important Message",
MessageBoxButtons.OK, MessageBoxIcon.Information);