Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update value dbo sql using vfp 8

Status
Not open for further replies.

WedHouse

Technical User
Apr 25, 2024
8
ID
ask for advice. how to update dbo sql values ??via vfp
The code script that I put in the button is as below:

nHandle=SQLSTRINGCONNECT("DSN=surya;UID=surya;PWD=surya_artha;DATABASE=bpr_arthasurya;")
If nHandle<0
AERROR(laError)
Suspend && an error happened
Endif

If SQLEXEC(nHandle,"SELECT * FROM DBO.log where inisial = 'RONY'","temp")<0
AERROR(laError)
Suspend && an error happened
Endif

select temp
replace inisial with 'YUS' all

* SET MULTILOCKS ON
* CURSORSETPROP('Buffering',5,'temp')
* CURSORSETPROP('Sendupdates',.T.,'temp')
* CURSORSETPROP('Tables','log','temp')
* CURSORSETPROP('KeyFieldList','trxid','temp')
* CURSORSETPROP('UpdatableFieldList','aplikasi, keterangan, inisial, waktu, otorisasi, host, id, cabang, grup, trxid','temp')
* CURSORSETPROP('UpdateNameList','aplikasi aplikasi, keterangan keterangan, inisial inisial, waktu waktu, ;
otorisasi otorisasi, host host, id id, cabang cabang, grup grup, trxid trxid','temp')

SQLEXEC(nHandle, "UPDATE log SET inisial = curReplications.inisial WHERE trxid = curReplications.trxid")
=tableupdate(.T.)

from the script the value is not updated in dbo sql.
can you help me to clarify this matter?
 
What is curReplications? Is that a local table/cursor in VFP or something on the server? You can't use a VFP table or cursor in a query you're sending to the server.

Tamar
 
Code:
SQLEXEC(nHandle,"SELECT * FROM DBO.log where inisial = 'RONY'","[highlight #FCE94F]temp[/highlight]")
This line puts the result in the VFP cursor named "temp".

It is not named curReplications.



Chriss
 
whoops.. curReplications.. is my mistake.. it is should be named with temp..
 
after i change temp with curReplications. still in my dbo sql not affected or updated inisial from 'RONY' to 'YUS'...
 
Sure, it's not the only problem with your code.

Code:
=tableupdate(.T.)
This line would only work, if you make the CURSORSETPROP calls you deactivated by commenting them.

Assuming you changed curReplications to temp anywhere, you instead use this:
Code:
SQLEXEC(nHandle, "UPDATE log SET inisial = temp.inisial WHERE trxid = temp.trxid")
Well, look at the result value and chevck, if an error is reported:
Code:
If SQLEXEC(nHandle, "UPDATE log SET inisial = temp.inisial WHERE trxid = temp.trxid")<0
   AERROR(laError)
   Suspend && an error happened
Endif
You already know a result <0 indicates an error, as your code used the same meachnism in your own code, there:
Code:
If SQLEXEC(nHandle,"SELECT * FROM DBO.log where inisial = 'RONY'","temp")<0
AERROR(laError)
Suspend && an error happened
Endif
Why don't you apply the patterns of code you already know?


Chriss

PS: If you ask me, the way to work with all the cursorsetprops and finally a TABLEUPDATE is better, as it will forward all changes (updates), new records (aqppend/insert) and also delete in the SQL server table what was deleted in the cursor, so it's one command for sending all the batch of changes to SQL Server, therefore it's worth doing the multiple CURSORSESDTPROPs in comparsion to single SQL Update, which obviously doesn't work the way you do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top