Data type mismatch for Insert Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suexicano
    New Member
    • Nov 2009
    • 6

    Data type mismatch for Insert Query

    Hi -

    Getting the famous Data type mismatch error with the following code. The CallComments is a Memo Data type ins Access 2007, and that is the data element causing the error.

    Code:
    this.Cursor = Cursors.WaitCursor;
    
    OleDbCommand objCmd = new OleDbCommand("", conn);
    objCmd.CommandText = "INSERT INTO LogTb (CallDate, PtLastName, PtFirstName, PtDOB, PtUniqueNo, PtPrimary, PtSecondary, PtTertiary, CallReason, CallComments)" 
    + "SELECT DISTINCT NOW(), ARdemoTb.PtLastName, ARdemoTb.PtFirstName, ARdemoTb.DateOfBirth, ARdemoTb.UniqueNo, ARdemoTb.PrimaryNo, ARdemoTb.SecondaryNo, ARdemoTb.TertiaryNo, " + uint.Parse(ReasonComboBox.SelectedValue.ToString()) + ", @MyClinicalNote FROM ARdemoTb WHERE ARdemoTb.UniqueNo=@UnqiueNoMe";
    
    
    objCmd.Parameters.Add("@MyClinicalNote",OleDbType.LongVarWChar).Value = CommentsTextBox.Text;
    objCmd.Parameters.AddWithValue("@UniqueNoMe", PtString.ToString());
    
               
    conn.Open();
    objCmd.ExecuteNonQuery();
    conn.Close();
                
    this.Cursor = Cursors.Default;
    Thanks for your help!
Working...