how to write insert query to insert combobox text to msaccess database

May 24 2009 4:01 AM

how to write insert query to insert combobox text to msaccess database

Hi , i have a combobox  CMBYEAR , i written this query to insert combobox data into the msaccess databse

but it is giving the error (Dara type mismatch in criteria expression) if i use textbox it is insertin fine why plss help me on this

my code is

OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");

string stroledb="insert into Student_Registration values('"+ txtstudentname.Text+"','"+ txtyear.Text+"','"+ txtbranch.Text+"','"+txtdoj.Text +"','"+ cmbyear.Text+"','"+txtemailid.Text +"','"+ txtmobileno.Text+"','"+txtaddress.Text +"')";

OleDbCommand aCommand = new OleDbCommand(stroledb, con);

aCommand.Connection.Open();

aCommand.ExecuteNonQuery();

aCommand.Connection.Close();


Answers (1)