2
Answers

Data type mismatch in criteria expression.

Ask a question
arun kumar

arun kumar

12y
2.3k
1
sir, i have problem insert a values in my access data base i have a error code: Data type mismatch in criteria expression. please kindly help me.

my code is

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;


namespace logins
{
    public partial class monthpur : Form
    {
        OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\ARUNKUMAR\\myproject\\myprojects\\data\\as.accdb");

        OleDbCommand com;
        string str;

        public monthpur()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }



        private void textBox7_TextChanged(object sender, EventArgs e)
        {



        }

        private void button1_Click(object sender, EventArgs e)
        {
            str = " insert into purmonth (" + "purchasedate," + "paiddate," + "cusid," + "cusname," + "mill," + "item," + "quantity," + "rate," + "debit," + "credit" + " )    values (('" + dateTimePicker1.Text  + "'),('" + paidBox.Text + "'),('" + cusBox.Text + "'),('" + cusnameBox.Text + "'),('" + millBox.Text + "'), ('" + comboBox1.SelectedItem + "'),('" + quantityBox.Text + "'), ('" + rateBox.Text + "'),('" + debitBox.Text + "'),('" + creditBox.Text  + "'))";
            //str = " insert into purmonth values (('" + dateTimePicker1.Text + "'),('" + dateTimePicker2.Text + "'),('" + textBox3.Text + "'),('" + textBox4.Text + "'),('" + textBox5.Text + "'), ('" + comboBox1.SelectedItem + "'),('" + quantityBox.Text + "'), ('" + rateBox.Text + "'),('" + textBox7.Text + "'),('" + creditBox.Text + "'))";
            com = new OleDbCommand(str, con);
            com.ExecuteNonQuery();

                    MessageBox.Show("Records Successfully Stored");

           // con.Close();

        }


        private void monthpur_Load(object sender, EventArgs e)
        {
            con.Open();

        }

        private void creditBox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                creditBox.Text = (decimal.Parse(quantityBox.Text) * decimal.Parse(rateBox.Text)).ToString();

            }
            catch
            {

            }

        }
    }
}

please kindly help me..
Thanking you..

Answers (2)
Next Recommended Forum