Hello
i have this error when i don't put image in insert form and i put the image in database is accept null why is that error show how is can fix.
this is the code inside the insert
private void btnOk_Click(object sender, EventArgs e)
{
if (state == "add")
{
MemoryStream ms = new MemoryStream();
pbox.Image.Save(ms, pbox.Image.RawFormat);
byte[] btimge = ms.ToArray();
pa.Add_Patients(txtPname.Text,txtPphone.Text,Convert.ToInt16(txtPage.Text),txtPaddress.Text, btimge,txtDetails.Text,Convert.ToInt32(CmbGender.SelectedValue),Convert.ToDateTime(dtpCheck.Text),
Convert.ToDateTime(dtpnextCheck.Text),Convert.ToDecimal(txtResMoney.Text),Convert.ToDecimal(txtIncomMoney.Text),
txtfrom.Text, txtto.Text);
MessageBox.Show("Patient is Added", "Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MemoryStream ms = new MemoryStream();
pbox.Image.Save(ms, pbox.Image.RawFormat);
byte[] btimge = ms.ToArray();
pa.Update_Patient(txtPname.Text, txtPphone.Text, Convert.ToInt16(txtPage.Text), txtPaddress.Text, btimge, txtDetails.Text, Convert.ToInt32(CmbGender.SelectedValue), Convert.ToDateTime(dtpCheck.Text),
Convert.ToDateTime(dtpnextCheck.Text), Convert.ToDecimal(txtResMoney.Text), Convert.ToDecimal(txtIncomMoney.Text),
txtfrom.Text, txtto.Text,Convert.ToInt32(txtPid.Text),Convert.ToInt32(txtRollID.Text));
MessageBox.Show("Patient is Update", "Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
PatientManage.getMainForm.dataGridView1.DataSource = pa.Get_all_Patients();
}
What I have tried:
i search in this problem but i didn't find what should i do