Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Begin Transaction
Message
 
 
To
27/09/2016 07:35:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01641395
Message ID:
01641397
Views:
58
Likes (1)
Your BEGIN TRANSACTION/END TRANSACTION has no effect for SQL Server and should not be used.

What is the exact purpose of your code? Can you tell in English what are you trying to achieve? I think you can perform all operations as one long command rather than doing 3 separate SQL commands.

>Dear Experts
>
>I am using SQLSERVER with VFP.
>
>I use Begin Transaction, but I doubt there is bug in my begin transaction---end transaction
>I found some time the last row of last vouchers missed.
>
>Please review my codes, How to make codes better to save data permanently on disk
>
>
>
>begin transaction
>sqlsetprop(m.con, "Transactions",2)
>
>lok=.t. && variable to dectect error
>
>cmd="delete from crpr_sum where date=?Thisform.text3.Value and vou_no=?Thisform.text1.Value"
>if sqlexec(con,cmd)<0
>	aerror(laerror)
>	messagebox(laerror[1,2])
>	lok=.f.
>	return.f.
>endif
>
>
>cmd="select MAX(vou_no)as max_sno from crpr_sum where date=?thisform.text3.Value"
>if sqlexec(con,cmd,'table1')<0
>	aerror(laerror)
>	messagebox(laerror[1,2])
>	return.f.
>else
>	select table1
>	thisform.text1.value=nvl(max_sno,0)+1
>endif
>
>
>text TO m.cmd NOSHOW TEXTMERGE 
>INSERT INTO crpr_sum(
>vou_no,date,vou_type,acc_code,acc_name,sales_r,vehicle_no,bilty_no,tpt,
>driver,cr_amount,dr_amount)
>values(
>?Thisform.text1.Value,?thisform.text3.value,'PR',?thisform.text10.value,
>?thisform.text11.value,?thisform.text13.value,?thisform.text14.value,
>?thisform.text15.value,?thisform.text16.value,?thisform.text2.value,
>?thisform.text22.value,0)
>ENDTEXT
>
>if sqlexec(m.con,cmd)<0
>	aerror(laerror)
>	messagebox(laerror[1,2])
>	lok=.f.
>endif
>
>if 	lok=.f.
>	sqlrollback(m.con)
>	rollback
>else
>	if sqlcommit(m.con)<0
>		aerror(laerror)
>		messagebox(laerror[1,2])
>		rollback
>	else
>		end transaction
>	endif
>	sqlsetprop( m.con,"Transactions",1)
>endif
>
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform