Syntax error in INSERT INTO statement
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.
Wild guess, but try to type [group] instead of just group. I assume the group word is reserved because of the "GROUP BY" clause.
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].
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
- .
精彩评论