"Data type mismatch in criteria expression"
        Posted  
        
            by simon
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by simon
        
        
        
        Published on 2010-05-02T14:07:31Z
        Indexed on 
            2010/05/02
            14:17 UTC
        
        
        Read the original article
        Hit count: 339
        
Hey guys ! I have a problem when i want to insert values from textboxes to my access database ! When i want to save i get that error ("Data type mismatch in criteria expression") The code: string conString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\Users\Simon\Desktop\test5\test5\test5\save.mdb";
        OleDbConnection empConnection = new OleDbConnection(conString);
        string insertStatement = "INSERT INTO aktivnosti_save "
                             + "([ID_uporabnika],[ID_aktivnosti],[kalorij]) "
                             + "VALUES (@ID_uporabnika,@ID_aktivnosti,@kalorij)";
        OleDbCommand insertCommand = new OleDbCommand(insertStatement, empConnection);
        insertCommand.Parameters.Add("@ID_uporabnika", OleDbType.Char).Value = textBox3.Text;
        insertCommand.Parameters.Add("@ID_zivila", OleDbType.Char).Value = iDTextBox.Text;
        insertCommand.Parameters.Add("@kalorij", OleDbType.Char).Value = textBox2.Text;
        empConnection.Open();
        try
        {
            int count = insertCommand.ExecuteNonQuery();
        }
        catch (OleDbException ex)
        {
            MessageBox.Show(ex.Message);
        }
        finally
        {
            empConnection.Close();
            textBox1.Clear();
            textBox2.Clear();   
        }
    }  
        © Stack Overflow or respective owner