0
votes
conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\database.mdb");
conn.Open();

com = new OleDbCommand(@"insert into group
                          (groupid,groupname,nature,effect) 
                         values 
                          (@groupid,@groupname,@nature,@effect)", conn);
com.Parameters.AddWithValue("@groupid", intialtxt);
com.Parameters.AddWithValue("@groupname", groupnametxt);
com.Parameters.AddWithValue("@nature", groupnaturecombo);
com.Parameters.AddWithValue("@effect", efectivegroupcombo);
com.ExecuteNonQuery();

conn.Close()

i have write this connection ,but i get one error Syntax error in INSERT INTO statement please someone help me.

3
@Kevin Thank you!!!! - rlb.usa

3 Answers

2
votes

Wild guess, but try to type [group] instead of just group. I assume the group word is reserved because of the "GROUP BY" clause.

1
votes

Ahhh MS Access with your exceedingly stupid naming allowances, from allowing spaces in table names to permitting use of SQL keywords for field names.

GROUP is a SQL reserved word. If you have the chance, I highly recommend you rename it. That said, if you can't rename it, surround it with square brackets in the query [group].

0
votes

OleDbCommand(@"insert into group(

You have some typos:

  • there should be a space between the table name and your open paren, like this : group (groupid
  • .