1

The SQL for creating Access table shows error:

string sql = "CREATE TABLE [" + textBox1.Text + "]([S.NO] INTEGER PRIMARY KEY AUTOINCREMENT, [Entry Date] DATETIME)";
OleDbCommand cmd = new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();
4
  • 1
    What is the error? BTW try removing the dot in the column name. Commented Dec 25, 2014 at 6:10
  • Visual Studio shows syntax error in CREATE STATEMENT. That's it. No brief explanation. Commented Dec 25, 2014 at 6:12
  • No. Didn't work. Same error. Commented Dec 25, 2014 at 6:14
  • As it turns out this question has nothing to do with C#. Commented Dec 25, 2014 at 9:05

1 Answer 1

2

Access considers INTEGER and AUTOINCREMENT to be two different data types. Don't declare your field as both.

Also Access complained when I requested S.NO as a field name. In order to get the statement to work I substituted an underscore for the dot:

CREATE TABLE [tblHarshan01]([S_NO] AUTOINCREMENT PRIMARY KEY, [Entry Date] DATETIME)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.