Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Again, troubles with CursorAdapter
Message
De
15/08/2003 23:54:43
 
 
À
15/08/2003 23:13:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00819734
Message ID:
00820702
Vues:
50
>>If connection is closed while there is in an active transaction, driver commits changes.
>>
>
>Really? Do you mean if the connection is NORMALLY closed? I assume that's what you mean, cause if the connection to the server drops (pc dies) then I always thought the server rolled back.
>
>I assume you mean if I do something like:
>
>
>nConn = sqlconnect(connection)
>
>SQLSetProp(nConn, "Transactions", DB_MANUAL)
>
>SQLExec("INSERT INTO MYTABLE VALUES MYVALUES")
>
>SQLDisq(nConn)
>
>
>That the odbc driver will commit this? If so, interesting info.
>
>BOb

Hi Bob,

If you don't believe me, try it for yourself:
CLOSE DATABASES all
CLEAR
?VERSION()
con=SQLCONNECT("LocalServer") && point to any available SQL Server

IF con<1
	? "FAILED to connect!!!"
	RETURN
ENDIF

cConnString=SQLGETPROP(con,"ConnectString")

SQLEXEC(con,"SET ANSI_PADDING ON")
SQLEXEC(con,"DROP table testtransaction3")
SQLEXEC(con,"create table testtransaction3 (f1 int, f2 char(10))")



SQLSETPROP(con,"Transactions",2)
SQLEXEC(con,"insert into testtransaction3 values(1,'11111')")
SQLEXEC(con,"select @@TRANCOUNT as count", "trancount")
? "Current trancount:",trancount.count
*SQLROLLBACK(con) && <==== uncomment this line to see the difference
? "Connection is disconnected!"
SQLDISCONNECT(con)

?
con=SQLSTRINGCONNECT(cConnString)
? "Connect again and query data"
SQLEXEC(con,"select * from testtransaction3","currentstate")
SELECT currentstate
LIST
?[RECCOUNT()],RECCOUNT()

SQLEXEC(con,"DROP table testtransaction3")
SQLDISCONNECT(0)
VFP output:
Visual FoxPro 08.00.0000.2521 for Windows
Current trancount:           1
Connection is disconnected!

Connect again and query data
Record#           F1 F2        
      1            1 11111     

RECCOUNT()          1
SQL Profiler output:
Audit Login
SQL:BatchCompleted	select USER_NAME() select usertype,type,name from systypes where usertype>=257
SQL:BatchCompleted	SET ANSI_PADDING ON
SQL:BatchCompleted	DROP table testtransaction3
SQL:BatchCompleted	create table testtransaction3 (f1 int, f2 char(10))
SQL:BatchCompleted	set implicit_transactions on 
SQL:BatchCompleted	insert into testtransaction3 values(1,'11111')
SQL:BatchCompleted	select @@TRANCOUNT as count
SQL:BatchCompleted	IF @@TRANCOUNT > 0 COMMIT TRAN <============== !!!
Audit Logout
Audit Login
SQL:BatchCompleted	select USER_NAME() select usertype,type,name from systypes where usertype>=257
SQL:BatchCompleted	select * from testtransaction3
SQL:BatchCompleted	DROP table testtransaction3
Audit Logout
Thanks,
Aleksey.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform