2012-03-03 5 views
1

저장 단추를 클릭하면 다음 오류가 표시됩니다. System.Windows.Forms.DateTimePicker 개체 유형에서 매핑이 없습니다. 알려진 관리 공급자 네이티브 형식).개체 유형 System.Windows.Forms.DateTimePicker에서 알려진 관리되는 공급자 네이티브 형식으로의 매핑이 없습니다.

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); 
    } 
} 

답변

4
cmd.Parameters.Add("@DOI", dtpc1); 

아마

cmd.Parameters.Add("@DOI", dtpc1.Value); 

cmd.Parameters.Add("@validtill", dtpc2); 

cmd.Parameters.Add("@validtill", dtpc2.Value); 
+0

감사해야해야합니다! 돌이켜 보면 분명하지만, 나는 아주 비슷한 오류를 겪고 있었고 그 원인을 두뇌 발달시키고있었습니다. – clweeks

관련 문제