hey..m a student of last year of BCA...i m making my project on crime management system...i had made my database in ACCESS 2003 n using the C# language...in database i hd taken the auto number as datatype in my serial number column.
bt when m accessing my code in C# at dat tym an error is coming dat syntax error in INSERT query.

Are you going to show us the INSERT statement or are we supposed to guess what you've done wrong?

hey..m a student of last year of BCA

Please STOP posting as though you were texting on your cellphone. This is a forum, not a cellphone. If you expect people to take you seriously then you need to spell out the words. There are lots of people here who do not know Engligh well enough to understand what you wrote.

commented: Engligh! +8
string query="insert into basic_info(sno,name,fathers_name,alias,age,education) values(0,'"+name.text+"','"+fathers_name.text+"','"+alias.text+"',"+age.text+",'"+education.text+"')";

Never use hard-coded SQL string. You should learn the Parameters.

string sql="INSERT INTO BASIC_INFO (sno,name,fathers_name,alias,age,education) VALUES (@sno,@name,@fathers_name,@alias,@age,@education)";

using(OleDbConnection cn=new OleDbConnection())
  using(OleDbCommand cmd=new OleDbCommand())
      cn.ConnectionString="Your connection String";



hey thanks for ur suggestion...but we have also tried this thing....in this it allows us only one entry during insertion....but when we tried next tym to insert new record in our database...it generates the duplication error....according to the error ..it again n agin took the 0 as a serial number. it doesn't incremented itself.

Is your serial number column set to auto-increment? If yes, pass it null instead of zero.
Once you have added parameters you do not need to add them again, simply change the value they hold:

cmd.Parameters["@name"].Value = new_value_to_insert;

That should get around the duplication error, if that is the problem you are seeing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.