Source language: Translate to:

Exporting and Importing data

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Exporting and Importing data

Postby carlos torres » Mon Oct 13, 2008 11:49 am

Hi everybody

I made an app that is able to copy/export an access MDB file... it works OK, but if that file has been modified (added,deleted, updated records) I don know how to upgrade the original file with those changed/added records.

- I tried creating a view but it returns zero records.
- I rename the target table then go through it checking one by one record but it doesn't work neither

I will appreciate your help, How can I copy/update records form a datafile to another one with the same name.

regards, thanks
carlost
User avatar
carlos torres
 
Posts: 289
Joined: Mon May 02, 2005 8:14 am
Location: Pamplona, Colombia

About importing/exporting data

Postby carlos torres » Tue Oct 14, 2008 8:14 am

Hi everybody

I found a solution not complicated as I was thinking to do:

1 - Open the original file (MDB) assign it an Alias
2 - Open the table you want to update
Code: Select all
dbpOpenAccessDatabase "Alias" "[PubDir]Data\YourFileName_[Year].mdb" "Password123"
    dbpOpenTable "Alias" "Db" ""
    ...///optional
    dbpSort "Alias" "Db" "[dBSort]=ASC"
    ...///optional
    dbpShowAll "Archivo" "Db"


3 - Open the exported database using (could be) with the same Alias plus a letter
Code: Select all
 dbpOpenAccessDatabase "AliasX" "[DriveLetter]\YourFilename_[Year].MDB" "Password123"
       dbpOpenTable "AliasX" "Db" ""
       dbpSort "ArchivoX" "Db" "[dBSort]=ASC"


4 - Make a loop checking each record
Code: Select all
 Loop "1" "[AliasX.Db.$RecCount]" "[i]"
            ...///
            dbpGotoRecord "AliasX" "Db" "[i]"
            ...///find that record on the original database/table
            dbpFind "Alias" "Db" "Field2Search" "[AliasX.Db.Field]" "ExactMatch=Yes;CaseSensitive=No"

            If "[dbpError]" ">" ""
               ...///no match Add to the original
               dbpAddRecord "Alias" "Db"
               GoSub "SetCopiedFields"
            Else
               ...///just update fields
               GoSub "SetCopiedFields"
               ...///
            EndIf
       EndLoop


The routine 'SetCopiedFields' just replace the original fields with the contents of the new ones.

Hopefully it will help someone else.

regards

carlost
User avatar
carlos torres
 
Posts: 289
Joined: Mon May 02, 2005 8:14 am
Location: Pamplona, Colombia


Return to NeoBookDBPro

Who is online

Users browsing this forum: Bing [Bot] and 2 guests