Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
0
down vote
favorite
I am trying to create a DBF table when i get this error "Syntax error in field definition." , however there is nothing wrong with syntax , and when I change a certain column name from level to levels it debug just fine! anybody have an idea ? here is the code:
C#
 string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= D://Temp;Extended Properties=dBase IV"; //MessageBox.Show(connectionString);

        OleDbConnection connection = new OleDbConnection(connectionString);
        connection.Open();



        /* ---------------------------  Filling The DBF Files ----------------------*/
        using (OleDbCommand cmd = connection.CreateCommand())
        {


            cmd.CommandText = @"CREATE TABLE clients(
                                                        nbrclient   int             ,   
                                                        level      varchar(1)      ,    
                                                        type        varchar(10)     ,
                                                        name        varchar(80)     ,   
                                                        name2       varchar(80)     ,   
                                                        fname       varchar(50)     ,   
                                                        vip         varchar(40)     ,
                                                        langue     varchar(3)      ,    
                                                        salutations varchar(30)     ,
                                                        gender      varchar(30)     ,
                                                        title       varchar(30)    
                                                        ) ";
cmd.ExecuteNonQuery();

      }
Posted
Comments
ZurdoDev 30-Apr-13 13:35pm    
level is likely a keyword.
SalouaK 30-Apr-13 13:38pm    
Yes, you are right , i reaserched the reserved words for dbase, and level is one of them! do you have anyidea how to escape it?
ZurdoDev 30-Apr-13 14:30pm    
I don't. I would recommend not using it. In Microsoft SQL you use square brackets around it, [level], but a better idea is to think of a different word.
Richard C Bishop 30-Apr-13 14:36pm    
I agree with ryanb31, do not ever use keywords as variable names. They are already being used. You cannot call a variable "int" in C#. It is reserved as is "level" in SQL.

Level is a reserved word. I would recommend not using it. In Microsoft SQL you use square brackets around it, [level], but a better idea is to think of a different word.
 
Share this answer
 
Yes , ryanb31 you're absolutly right , Level is a reserved word and the best thing is t not use reservedword a think of a better nomenclature , but since a whole system use those same nomenclature I cannot change, at least not right now, The good News is I have find a work around, Use (`) before and after the reserved word so instead of level `Level` passed with no problem at all Be careful not to confuse (') with (`).
thank you all for your good word and advise
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900