Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
                      OleDbConnection con = new OleDbConnection();
           con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Application.StartupPath + "\\kodmatikdatabase.accdb";

con.Open();
           OleDbCommand sorgu = new OleDbCommand(("insert into geneltablo (KodAdi,Aciklama,GirisTarihi,Link,ProgramlamaDili,Puan,Durum) values (@KodAdi,@Aciklama,@GirisTarihi,@Link,@ProgramlamaDili,@Puan,@Durum)"),con);
           sorgu.Parameters.AddWithValue("@KodAdi", textBox1.Text);
           sorgu.Parameters.AddWithValue("@Aciklama", richTextBox1.Text);
           sorgu.Parameters.AddWithValue("@GirisTarihi", dateTimePicker1.Text);
           sorgu.Parameters.AddWithValue("@Link", textBox2.Text);
           sorgu.Parameters.AddWithValue("@ProgramlamaDili", comboBox1.Text);
           sorgu.Parameters.AddWithValue("@Puan", comboBox3.Text);
           sorgu.Parameters.AddWithValue("@Durum", comboBox2.Text);


           sorgu.ExecuteNonQuery();



when i push button


" sorgu.ExecuteNonQuery(); " in this line

always give me this error

"Data type mismatch in criteria expression."


What is wrong ? :confused::confused::confused:
Posted

1 solution

I suspect the problem is here:

sorgu.Parameters.AddWithValue("@GirisTarihi", dateTimePicker1.Text);

If the target field is a datetime value in the Access database, this will cause an error. You'll need to cast this value to a datetime before you add the parameter. Additionally, if any of the other parameters are numeric values in the database, you'll need to cast the xx.Text value into the appropriate numeric type.
 
Share this answer
 
Comments
kozmikadam 31-Jul-10 11:09am    
problem solved thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900