locked
create table dbase IV RRS feed

  • Question

  • Hello!

    I have to create -- ar runtime -- some dbf in dbase IV format. I am using Visual C# and System.Data.OleDb (I tried also System.Data.Odbc).

    My approach is like this:

    1/ create oledbconnection with connection string Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\somefolder;Extended Properties=dBASE IV;

    2/ create oledbcommand object and setting the commendtext: create table tablename(columnname numeric(13,3)) and perform executenonquery.

    The file is created but the column is not exactly as I wanted; instead it's numeric(20,5).

    My question is: how to create a numeric data type column exactly the precision and width I specify?

    Thank you for your time,

    Augustin Calin

    Wednesday, October 11, 2006 11:07 AM

Answers

  • This is not a dBase forum and I think you'd get better replies on dBase sites.

     

    I wouldn't use Jet driver in the first place. Probably Advantage Database Server has better drivers for dBase too. Check their site. If not, try using VFPOLEDB driver instead unless you really have to create in dBase IV format.

     

    PS: Actually creating a DBF table (or editing the header to change field type,size,precision) using plain file IO in C# is fairly easy.  I know table header structures for foxpro tables but not for dBaseIV. I beleive you would find that information on the internet.

     

    Tuesday, June 24, 2008 7:15 AM
  • I see. Then you can use VFPOLEDB. To do that use Execscript command as a stored procedure and code to create the table in fox2x format as its parameter. Something like:

     

    Code Snippet

    string cmdScript = @"create table myTempTable free (myField n(13,3), myField2 c(10))

    copy to myTable type fox2x";

     

    OleDbConnection cn = new OleDbConnection(@"provider=VFPOLEDB;Data Source=c:\myFolder\");

    OleDbCommand cmd = cn.CreateCommand();

    cn.Open();

    cmd.CommandType = CommandType.StoredProcedure;

    cmd.CommandText = 'ExecScript";

    cmd.Parameters.Add("Script",OleDbType.Char).Value = cmdScript;

    cmd.ExecuteNonQuery();

    con.Close();

    // erase temp myTempTable which is not fox2x compatible

     

     

     

    Tuesday, June 24, 2008 1:35 PM
  • No, it is not possible as it is over the limit.

    BTW, the dBASE IV file structure is detailed here.

    For information, the FoxPro field sizes are here.
    Monday, September 8, 2008 11:18 AM

All replies

  •  

    Hi

    I found the same problem on SSIS program generate the dBase5 format.

     

    Tuesday, June 24, 2008 6:54 AM
  • This is not a dBase forum and I think you'd get better replies on dBase sites.

     

    I wouldn't use Jet driver in the first place. Probably Advantage Database Server has better drivers for dBase too. Check their site. If not, try using VFPOLEDB driver instead unless you really have to create in dBase IV format.

     

    PS: Actually creating a DBF table (or editing the header to change field type,size,precision) using plain file IO in C# is fairly easy.  I know table header structures for foxpro tables but not for dBaseIV. I beleive you would find that information on the internet.

     

    Tuesday, June 24, 2008 7:15 AM
  • Hi CetinBasoz

     

    Thanks for your repely. Actually I try to found the solution in google but found nothing. Some one is said that is bug for the microsoft jet oledb 4.0. In fact I want to use the SSIS to genreate a dbf file can open by access and foxpro 2.6.

    I have been try to use the VFPOLEDB, but when I use the VFPOLEDB driver to generate the dbf file the old version foxpro(2.6) can not open the generated dbf file.

    Tuesday, June 24, 2008 7:26 AM
  • I see. Then you can use VFPOLEDB. To do that use Execscript command as a stored procedure and code to create the table in fox2x format as its parameter. Something like:

     

    Code Snippet

    string cmdScript = @"create table myTempTable free (myField n(13,3), myField2 c(10))

    copy to myTable type fox2x";

     

    OleDbConnection cn = new OleDbConnection(@"provider=VFPOLEDB;Data Source=c:\myFolder\");

    OleDbCommand cmd = cn.CreateCommand();

    cn.Open();

    cmd.CommandType = CommandType.StoredProcedure;

    cmd.CommandText = 'ExecScript";

    cmd.Parameters.Add("Script",OleDbType.Char).Value = cmdScript;

    cmd.ExecuteNonQuery();

    con.Close();

    // erase temp myTempTable which is not fox2x compatible

     

     

     

    Tuesday, June 24, 2008 1:35 PM
  • hi

    i have some pblm in generating dbf file from c#.net with dbf IV oledb provider.

    when i try to Crete a numeric field of (25,8) length it show error as max lenght is 20 for numeric field.
    but our client want field of (25,8) width only.

    can u tell me is it possible any way to create a numeric field in dbf file with (25,8) width.
    Sunday, September 7, 2008 6:33 AM
  • No, it is not possible as it is over the limit.

    BTW, the dBASE IV file structure is detailed here.

    For information, the FoxPro field sizes are here.
    Monday, September 8, 2008 11:18 AM