Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updating an older Access file (mdf) from VFP
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01674938
Message ID:
01674941
Vues:
55
>>>Hi,
>>>
>>>I am trying to update an older Access file from VFP.
>>>I am able to open the mdf file, and read the table I wish to update into a cursor.
>>>I update the contents of the cursor, but ab unable to write back the changes to the source table.
>>>
>>>Code:
>>>
>>>nAccessHandle = sqlstringconnect( "DRIVER=Microsoft Access Driver (*.mdb, *.accdb); DBQ=C:\Ndb5.mdb;" )
>>>
>>>if nAccessHandle < 1
>>>   messagebox( "Invalid connection to access database" )
>>>   return
>>>endif 
>>>
>>>nSQLAns = SQLExec( nAccessHandle, "select number, name, phone, name1 from directory", "tbcurs" )
>>>
>>>if nSQLAns < 1
>>>   messagebox( "Unable to get any data..." )
>>>   sqldisconnect( nAccessHandle )
>>>   return
>>>endif
>>>
>>>
>>>select tbcurs
>>>use c:\TB order gcode in 0 alias TB
>>>set relation to left(number,6) into tb
>>>replace name1 with tb.unit for !eof('tb')
>>>
>>>=tableupdate(1,.t.,) && does not work!!
>>>
>>
>>Can you just send direct update command back (e.g. not try to use tableupdate, but rather send generate update command in VFP and send it back to Access same way you get the data)?
>
>Hi Naomi,
>Never done this before, so basically trying various things in the hope that one sticks :)
>Tried messing around with the update command - cannot seem to get that to work. I don't want to use insert as I don't want to add records - just update one field in the existing records in the table.
>
>Tks

Finally got it to work using:
   go top
   scan
      csql="update directory set name1='"+tbcurs.name1+"' where number='"+tbcurs.number+"'"
      =sqlexec(nAccessHandle,csql)
   endscan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform