0

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:

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();
  }

3 Answers 3

4

Level is probably a reserved word. This worked when I tried it:

[level]      varchar(1),
0

Try to replace VARCHAR type to CHARACTER.

0

Yes , @LarsTech you're absolutly right , The good News is I have find a work around, Use () before and after the reserved word so instead of levelLevelpassed with no problem at all Be careful not to confuse (') with (). thank you all for your good work and advise

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.