HOW TO ADD AUTOMATICALLY A LOT OF .dbf FILE INTO A DATABASE .dbc FILE ???

Hi!

In a folder I have a lot of .dbf file!

I want to do the upsize to a MSDE, but I can't do it from a folder that contains the .dbf file....I need a .dbc file!

So, when I create a new .dbc file from the project manager, fox can't allow me to add automatically all the .dbf file that are in my folder! I must add one by one...but this procedure is too much slow!

Can you tell me how to add automatically a lot of .dbf file into a .dbc

If exist something to do that in fox pro, or with a code example....

Thank you



Answer this question

HOW TO ADD AUTOMATICALLY A LOT OF .dbf FILE INTO A DATABASE .dbc FILE ???

  • neorsp

    Ok...thank you...this code do what I want!

    But I have one more problem...the tables that I want to add into my Database are in Fox 3.0 format, and when I add one of it, Visual fox get me a message box with tis text: "File 'TABLENAME.dbf ' will be updated in new file format, making it unreadable, to previus version of FoxPro. This can be reversed with 'COPY TO' command, and the old table will be saved as a .BAK file. Continue " and I have two button OK,  and NO!

    But I want that my program choose automatically the OK button! Is it possible

    And then...can I save my new database, with my new tables in another folder not in the star folder ( getdir() )


    And...you tell me that I don't need the .dbc file to do the upsizing....how can I upsize a lot of .dbf file into an MSDE without upsizing wizard Is it possible Is more faster if I use the upsizing wizard...I think...or not

    Thank you so much for your help!


  • tcochran64

    VFP has a lot of functions and commands that lets you to analyze existing data files and create new ones programmatically. ie:

    create NewDbc
    use oldTable
    afields(laStruc)
    create table newTable from array laStruc
    append from oldTable

    However since you're using wizard pressing OK button is not a big deal. Wizard already itself has a UI.

    Yes you don't need the DBC. Purchase SQL server developer edition (42-49$). You can use DTS for upsizing.

    Also here is a sample upsizing in code (wouldn't work as is under all circumstances):

    Local lnHandle, lcDatabaseName,lcFreeDir,ix
    Local Array laDBF[1]
    lcFreeDir = "d:\fpd26\tutorial"
    lcDatabaseName = "myUpsizeTest"

    lnHandle=Sqlstringconnect('DRIVER=SQL Server;'+;
       'SERVER=(local);Trusted_connection=Yes')
    SQLExec(m.lnHandle, "create database "+m.lcDatabaseName) < 0
    SQLExec(m.lnHandle,"use "+m.lcDatabaseName)
    For ix=1 To Adir(laDBF,Addbs(m.lcFreeDir)+'*.dbf')
      SQLExec(m.lnHandle, ;
       " SELECT * "+;
       " into "+
    Juststem(laDBF[m.ix,1])+;
       " FROM OPENROWSET('VFPOLEDB', '"+
    Addbs(m.lcFreeDir)+"';'';'',"+;
       " 'select * from "+
    Juststem(laDBF[m.ix,1])+"') " )
    Endfor
    SQLDisconnect
    (m.lnHandle)


  • Przemek Wasylko

    My bad. In originl code I posted there was an if..endif conrtrol there. While removing the if I forgot < 0 at the end of code.

  • Arty S

    What I am saying is if you use programmatic conversion you don't get a dialog to click 'OK'.

  • LeeRivers

    Thank you cetin!

    But the command SQLEXEC(m.lnHandle, "create database "+m.lcDatabaseName) doesn't run!

    It doesn't create me a new database Why

    Please reply me in mine other thread!


  • Dominique Gratpain

    Thank you!

    But I have to start from a folder, where I have a lot of single table file making with old version of fox(3.0)...

    And I need to add all of that in a .dbc file, but, when I start my program, fox asked me everytime if I want to update my table...and everytime I must click OK!
    I want only know, if is possible to making foxpro code, that don't show me the 'foxpro update window' but choose automatically the OK button!







  • JayAllen

    1) You don't need a dbc for upsizing (maybe you do if you mean wizard).
    2) You can use:

    lcPath = getdir()
    create database (addbs(m.lcPath) + "myDatabase")
    for ix=1 to adir(aTables, addbs(m.lcPath)+'*.dbf')
     add table (addbs(m.lcPath)+aTables[m.ix,1])
    endfor

    3) You don't need to shout when asking questions (upper cases are considered to be shouting:)

  • HOW TO ADD AUTOMATICALLY A LOT OF .dbf FILE INTO A DATABASE .dbc FILE ???