2012-03-03 26 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("@validtill", dtpc2.Value); 
+0

おかげでなければなりません

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

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

する必要があります!私はかなり似たようなエラーを抱えていたし、思い通りに回っているにも関わらず、頭を悩ませていた。 – clweeks

関連する問題