problem with ms access connectivity in c#

Not open for further replies.


In the zone
i developed a window application(a aregistration form) and tried to store the details in a database. i used ms access. here is the method for the "submit" button that would store the details in the database. my database name is Registration and table name is Registration

private void btnRegister_Click(object sender, EventArgs e)

string strConnection =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\NewReg\\Registration.mdb";
OleDbConnection con = new OleDbConnection(strConnection);
string strQuery =
"select * from Registration";
OleDbCommand aCommand1 = new OleDbCommand(strQuery, con);
OleDbDataAdapter adp = new OleDbDataAdapter(aCommand1);
adp.SelectCommand = aCommand1;
DataSet ds = new DataSet();
adp.Fill(ds, "Registration");
DataRow drow = ds.Tables[0].NewRow();
drow[0] = txtName.Text;

drow[1] = int.Parse(txtAge.Text);

drow[2] = txtGender.Text;

drow[3] = txtPassword.Text;

drow[4] = int.Parse(txtContact.Text);
drow[5] = txtMail.Text;

OleDbCommandBuilder builder = new OleDbCommandBuilder(adp);

adp.UpdateCommand = builder.GetUpdateCommand();



but i get exceptions stating "syntax insert into exception". why such an exception? help plz.
also i'm not much familiar with MS connectivity using C#. any sites or links from which i can learn more about it..
Not open for further replies.
Top Bottom