Hi Guys,
I am using access (.mdb) database in my windows application. When i am inserting values to db it gives me an error "syntax error in insert into statement" but it will work in SQL and access query analyzer.
here is my code
string StrInsertToServer1 = "insert into Registration_master (stud_id, stud_name, add1, add2, add3, phone_no, mobile_no, dob, college_name, college_no, tuition_name, tuition_no, username, password, machinecode,recharge_code) values('" + txtstud_id.Text + "','" + txtstudName.Text + "','" + txtAddress1.Text + "','" + txtAddress2.Text + "','" + txtAddress3.Text + "','" + txtPhoneNo.Text + "','" + txtMobNo.Text + "','"+ dtpdob.Value.ToString() +"','" + txtCollName.Text + "','" + txtCollPhoNo.Text + "','" + txtTutName.Text + "','" + txtTutPhoNo.Text + "','" + txtUsername.Text + "','" + txtpassword.Text + "','" + txtmachine.Text + "','" + InRecharge + "')";
Ocmd = new OleDbCommand (StrInsertToServer1, Connect.AccConn ());
Ocmd.Connection.Open();
Ocmd.ExecuteNonQuery();
Ocmd.Connection.Close();
here is my connection string
public static OleDbConnection AccConn()
{
//Access 2002-03
return new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\Data\\SonamDb.mdb");
//Access 2007
// return new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\Data\\SNDB.accdb;Persist Security Info=False;");
}
Direct query will working..
can anybody tell me where i am going wrong....
Any help will be appreciated
Thanks in advance