Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Importing from Access
Message
From
12/12/2001 01:28:52
 
 
To
12/12/2001 01:14:58
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00593109
Message ID:
00593110
Views:
21
This message has been marked as a message which has helped to the initial question of the thread.
Hi, Michel.

That´s really a huge gap on the importing features...

yesterday I found the following code, which may help you... I don´t who´s the autor... if anybody know, please give the credits here...
LOCAL lcMyFile, lnConnHandle, lnResult, lcSQLCommand, lnGetData, lcNewName
LOCAL ARRAY laWhatErr(1)

lcMyFile = GETFILE('MDB')

*!* No point if no MDB file is selected
IF !EMPTY(lcMyFile)
   *!* Use a SQLStringConnect to connect to the MDB file
   lnConnHandle = ;
      SQLSTRINGCONNECT('DRIVER=MICROSOFT ACCESS DRIVER (*.MDB);DBQ=' + ;
         lcMyFile)
      
   IF lnConnHandle > 0
      *!* Need to know what tables are contained in the MDB file
      lnResult = SQLTABLES(lnConnHandle, 'TABLE')
      
      IF lnResult > 0
         *!* Create a new DBC named "MYNEW"
         CREATE DATABASE mynew
         *!* Select SQLResult and scan through the cursor.
         SELECT SQLResult
         SCAN
            *!* Build a SQL SELECT statement to pass to SQLEXEC()
            lcSQLCommand = ;
               "SELECT * FROM [" + ALLTRIM(SQLResult.table_name) + "]"
               
            lnGetData = SQLEXEC(lnConnHandle, lcSQLCommand, 'newdata')
            IF lnGetData > 0
               *!* SQLEXEC() was successful
               lcNewName = STRTRAN(ALLTRIM(SQLResult.table_name), " ", "_")

               SELECT newdata
               *!* Copy Table Structure and Data to a DBF file
               *!* VFP 3.0 - loses long field names
               *!* COPY TO (lcNewName)
               *!* ADD TABLE (lcNewName)
		   *!* VFP 5.0/6.0 - keeps long field names
               COPY TO (lcNewName) DATABASE myNew
            ENDIF
         ENDSCAN
      ENDIF
      *!* Done Getting Data, so Disconnect
      =SQLDISCONNECT(lnConnHandle)
   ELSE
      *!* The SQLStringConnect failed
      =MESSAGEBOX('ODBC Connection Failed', MB_ICONEXCLAMATION, 'ODBC')
      *!* Call AERROR()
      =AERROR(laWhatErr)
      *!* Display the error
      DISPLAY MEMORY LIKE laWhatErr
   ENDIF
ENDIF

BROWSE FIELDS table_name 
Claudio Lassala
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform