C#+ Syntax error in Create Table statement+ Urgent!!!!!!!!!!

csharp , db Adelaide, Australia
  • 12 years ago

    hi all,

     

    i have to create table in MS Access database through CREATE TABLE statement. But everytime i get Syntax error in Create Table Statement. 

    "CREATE TABLE IF NOT EXISTS " + pay_table + " (sn AUTOINCREMENT, Instalment_Amount Currency, Other Currency)";

     

     

    if i don't supply table name as variable  everything is ok.

     

     

    "CREATE TABLE IF NOT EXISTS  table_yes(sn AUTOINCREMENT, Instalment_Amount Currency, Other Currency)";

     

    please help me

     

    Thanks

    Radhika 

  • 12 years ago

    Hi,

    Looking at Access Help, the create statement looks something like this:

    CREATE [TEMPORARY] TABLE table (field1 type [(size)] [NOT NULL] [WITH COMPRESSION | WITH COMP] [index1] [, field2 type [(size)] [NOT NULL] [index2] [, ...]] [, CONSTRAINT multifieldindex [, ...]])

    I opened a query window and executed the following (which gave me the syntax error):

    CREATE TABLE IF NOT EXISTS StatementA (sn AUTOINCREMENT, Instalment_Amount Currency, Other Currency)

    Executing this, however did not give the error:

    CREATE TABLE StatementB (sn AUTOINCREMENT, Instalment_Amount Currency, Other Currency)

    Perhaps, you can try removing "IF NOT EXISTS" and trapping the exception when executing the create and the table is present.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.” - Jamie Zawinski