Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Advantage Database
Message
De
16/03/2006 23:28:46
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Divers
Thread ID:
01104479
Message ID:
01105193
Vues:
21
Hi Sandy,
I do this with some Advantage tables that I import. They may have other types of files, so I don't know if this will work for you. I stuff an array, aFileNames, with the files I want to import.
PROCEDURE SetConnection()
   LOCAL RetVal, OpenReturn, oException AS Exception 
   This.oConnection=CREATEOBJECT("ADODB.connection")
   IF VARTYPE(This.oConnection)=="O"
      RetVal = .T.
      TRY
         WITH This.oConnection
            .Provider= "Advantage OLE DB Provider"
            .ConnectionString = "ServerType=ADS_LOCAL_SERVER"
            .Properties.Item["Data Source"].Value = This.Folder
            .Properties.Item["Advantage Server Type"].Value = "ADS_LOCAL_SERVER"
            OpenReturn = .Open()   && Returns Null when successful, FWIW.
         ENDWITH
      CATCH TO oException
         This.Message = "Be sure you have installed this file: ADSOLEDB.EXE" + CRLF + oException.Message
         RetVal = .F.
      ENDTRY
   ELSE
      This.Message = "Unable to create the Connection to the Advantage tables."
   ENDIF
   RETURN m.RetVal
ENDPROC

PROCEDURE GetData()
   LOCAL FileName, Type, RecNo, VarType, Value, x
   WITH This.oRecordSet
      FOR EACH FileName IN This.aFileNames
         This.SetStatus("Opening file: " + m.FileName + "...")
         IF FILE( ADDBS(This.Folder) + m.FileName + ".ADT")
            .Open("Select * From " + m.FileName, This.oConnection)
            IF .State = 1
               RecNo = 1
               DO WHILE NOT .EOF
                  FOR x = 0 TO .Fields.Count-1
                     FieldName = .Fields.Item[x].Name
                     Type = .Fields.Item[x].Type
                     VarType = VARTYPE(.Fields.Item[x].Value,.T.)
                     Value = TRANSFORM(.Fields.Item[x].Value)
                     INSERT INTO MyTable FROM MEMVAR
                  ENDFOR
                  .MoveNext()
                  RecNo = m.RecNo + 1 
               ENDDO
            ENDIF
            .Close()
         ENDIF
      ENDFOR
   ENDWITH
   This.SetStatus("")
   RETURN 
ENDPROC
Charlie
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform