Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL server
Message
De
07/09/2002 12:43:03
 
 
À
07/09/2002 12:25:04
Brian Roberts
Software Alternatives, Inc.
Houston, Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00697921
Message ID:
00697924
Vues:
13
This message has been marked as the solution to the initial question of the thread.
Brian,

In order to make a SQL passthrough cursor updatable, you have to set a few more properties. To commit the changes, you use TABLEUPDATE(). Try the following against the northwind customers table:
?SQLEXEC(lnSql, "SELECT customerid, companyname FROM customers", "customers")
=CURSORSETPROP("Tables", [dbo."customers"])
=CURSORSETPROP("UpdateNameList", [customerid dbo."customers"."customerid", companyname dbo."customers"."companyname"] )
=CURSORSETPROP("KeyFieldList", "customerid" )
=CURSORSETPROP("UpdatableFieldList", "customerid companyname" )
=CURSORSETPROP("SendUpdates", .t.)
REPLACE companyName WITH UPPER(companyName)
?TABLEUPDATE()
Hope this gets you started.

>I am trying to use SQL server for the first time and I am having trouble.
>
>Server box: Windows 2000 Advanced server; SQL 2000 running
>
>System DSN has been defined for SQL
>
>I have writen a small .prg using the Northwind database that comes with SQL2000. Using a remote view, I can update the 'products' table, however I cannot get the SQLCOMMIT() command to actually update the table.
>
>Here is the code:
>
>BLR = SQLCONNECT('sql')
>TT='select * from products'
>SQLEXEC(BLR,TT,'tmpfile')
>SQLSETPROP(BLR,"Asynchronous",.F.)
>SQLSETPROP(BLR,"BatchMode",.T.)
>SQLSETPROP(BLR,"Transactions",2)
>cursorsetprop('SendUpdates',.t.,'tmpfile')
>cursorsetprop('Tables',products)
>replace tmpfile.productname with 'test'
>TTT=SQLCOMMIT(BLR)
>wait window " sqlcommit returned " + alltrim(str(ttt))
>SQLDISCONNECT(BLR)
>
>The 'TTT' variable ALLWAYS returns a '1', but when I open another connection to check the table, no updates have been written!
>
>I am VERY new to using SQL on the back end and have absolutely no idea what is wrong. What I need is a sample of code that opens a sql table, changes a field, and actually updates the sql table.
>
>Thanking you in advance....
>
>Brian Roberts
>(a very confused programmer)
Daniel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform