I tried to save two image from two picture box to database but images not add to related columns only the first image save to all column, I need solution for this issue (Code).
try
{
if (isNIDValid == true & isNameValid == true & isFNameValid == true & isGFNameValid == true & isEmailValid == true & isPhoneValid == true)
{
byte[] img = null;
FileStream fs = new FileStream(imageLocation, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
img = br.ReadBytes((int)fs.Length);
string sql = "insert into owner(NID, owner_name, F_Name, G_Name,Email,Phone_No, Gender,NID_Photo, Owner_Photo)values('" + txtnid.Text + "', '" + txtname.Text + "', '" + txtfathername.Text + "','" + txtgrandfathername.Text + "','" + txtEmail.Text + "','" + txtPhone.Text + "', '" + Gender + "', @img,@img)";
Connectivity.openConnection();
da.InsertCommand = new SqlCommand(sql, Connectivity.cn);
da.InsertCommand.Parameters.Add(new SqlParameter("@img", img));
int x = da.InsertCommand.ExecuteNonQuery();
MessageBox.Show(x.ToString() + "Record Saved");
showData("select * from owner");
}
else
lblSaveError.Text = "Please Re-enter the correct data.";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}