I am getting the following error when i click on save button(No mapping exists from object type System.Windows.Forms.DateTimePicker to a known managed provider native type).
private void btnSave_Click(object sender, EventArgs e)
{
//if (Isvalid())
{
SqlCommand cmd = new SqlCommand("sp_rcdoc", con);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add("@regno", tbx1.Text);
cmd.Parameters.Add("@appname", tbx2.Text);
cmd.Parameters.Add("@DOI", dtpc1);
cmd.Parameters.Add("@COV", cmbx.Text);
cmd.Parameters.Add("@validtill", dtpc2);
cmd.Parameters.Add("@imgloc", ScanDlg.path);
// cmd.Parameters.Add("@username", Login.currentuser);
// cmd.Parameters.Add("@imgno", popuprds.nofrecords);
cmd.Parameters.Add("@result", SqlDbType.Int).Direction = System.Data.ParameterDirection.Output;
if (con.State != ConnectionState.Open)
con.Open();
cmd.ExecuteNonQuery();
int i = Convert.ToInt16(cmd.Parameters["@result"].Value);
if (i > 0)
{
MessageBox.Show("Record inserted", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
pbx.Image = ScanDlg.img;
pbx.Load(@"E:\DMSProject\WindowsFormsApplication1\PROJECT SCANNED\ image0.jpeg");
//pictureBox1.Load(@"C:\Users\chandrasekhar\Desktop\PROJECT SCANNED\ image.jpeg");
}
else
MessageBox.Show("Record not inserted", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
cmd.Parameters.Add("@DOI", dtpc1);
should probably be
cmd.Parameters.Add("@DOI", dtpc1.Value);
and
cmd.Parameters.Add("@validtill", dtpc2);
should be
cmd.Parameters.Add("@validtill", dtpc2.Value);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.