Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Records From VFP To Append to MS Access Table
Message
 
À
15/02/2010 13:05:56
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01302047
Message ID:
01449243
Vues:
45
Cetin

Thank you very much

Colin

>>Cetin
>>
>>Saw this code of yours and wondered if you could help me
>>
>>I have an empty mdb database called flights with a numeric fields called serialno
>>
>>I have an table called serial.dbf which contains serial nos - I find the last record on this file and I want to create a new record on the mdb file so that flights.serialno (the mdb file) =serial.serialno (from the dbf)
>>
>>Can you help?
>>
>>Colin
>>
>
>
>Local loAccess As CursorAdapter,;
>  oConn As ADODB.Connection,;
>  oRS As ADODB.Recordset, ;
>  oException As Exception, ;
>  cConnString As String
>
>* Handle connections - insert connection code
>cConnString = [Provider=Microsoft.ACE.OLEDB.12.0;]+;
>  [Data Source=]+;
>  FULLPATH('MyAccessDatabase.mdb')+;
>  [;Persist Security Info=False]
>
>Try
>  oConn  = Createobject('ADODB.Connection')
>
>  * Ensure that you handle userid and password if not
>  * specified in connection string.
>  *   ex. oConn.Open(cConnString, userid, password)
>  oConn.Open(cConnString)
>
>  oRS = Createobject("ADODB.Recordset")
>  oRS.Datasource.CursorLocation = 3   &&adUseClient
>  oRS.Datasource.LockType = 3   &&adLockOptimistic
>  oRS.ActiveConnection = oConn
>
>  oCA=Createobject("CursorAdapter")
>  oCA.DataSourceType = "ADO"
>  oCA.Datasource = oRS
>  oCA.MapBinary = .T.
>  oCA.MapVarchar = .T.
>
>  oCA.Alias = "flights"
>  oCA.SelectCmd = "SELECT * FROM flights where (1=2)"
>
>  If !oCA.CursorFill()
>    * Replace with error code here
>    Local laError
>    Dimension laError[1]
>    Aerror(laError)
>    Messagebox(laError[2])
>  Else
>    * Replace with user code here. Code below allows for
>    * you to edit and send updates to the backend.
>    Local laFlds,lcStr,lnFldCount,i
>    Dimension laFlds[1]
>    lnFldCount=Afields(laFlds)
>    lcStr=""
>    For i = 1 To lnFldCount
>      lcStr = lcStr + laFlds[m.i,1] +  ","
>    Endfor
>    oCA.UpdatableFieldList = lcStr
>    
>
>SELECT 0
>USE serial
>GO botto
>luSerial = serial.serialno
>USE
>
>    Insert Into flights (serialNo) Values (?m.luSerial)
>    
>    Tableupdate(2,.T.,'flights')
>    Browse Normal
>  Endif
>
>Catch To oException
>  * Replace with exception handling code here
>  Messagebox(oException.Message)
>Endtry
>
>
>You could do that with a direct SPT call too (but I prefer CA).
>
>Cetin
Specialist in Advertising, Marketing, especially Direct Marketing

I run courses in Business Management and Marketing
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform