Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Begin Transaction
Message
From
28/09/2016 09:09:59
 
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:
01641445
Views:
42
>Tariq,
>
>As I said to you, you need to run all your SQL code as one batch, .e.g.
>
>text to lcSQLCommand textmerge noshow
>
> begin transaction
>
> delete from ...
>
> insert into ...
>
> commit transaction
>
>endtext
>
>In other words, instead of 3 separate blocks of sqlexec you would use a single command. The transaction must be on SQL Server side, not in VFP side where it has no bearings for your SQL Server and serves no purpose.

>
>Try to change your code yourself the way I am suggesting to you, post the result here for our inspection, then proceed.


Dear Teacher, I made an effort to merg my 3 queries into SINGLE query to complete a batch of transaction.
Please review
text TO m.cmd NOSHOW TEXTMERGE 

begin transaction

&& First Command
delete from crpr_sum where date=?Thisform.text3.Value and vou_no=?Thisform.text1.Value

&& Second Command
select MAX(vou_no)as max_sno from crpr_sum where date=?thisform.text3.Value"

&& Result of second command
thisform.text1.value=nvl(max_sno,0)+1

&& Third Command

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 sqlcommit(m.con)<0
		aerror(laerror)
		messagebox(laerror[1,2])
		rollback
	else
		end transaction
	endif


endif

endtext
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform