Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Thursday, May 2, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - ADO General
Forum to discuss ADO specific questions for use with SalesLogix. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to ADO General | New ThreadView:  Search:  
 Author  Thread: Transactions
Vladimir
Posts: 93
 
TransactionsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 30 Oct 07 4:32 AM
Has SLX any tools to use transactions?
DB - MSSQL 2000/2005

[Reply][Quote]
Bob (RJ)Ledger
Posts: 1103
Top 10 forum poster: 1103 posts
 
Re: TransactionsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Oct 07 9:56 AM
If you are talking about basic transaction support ath teh ADO recordset level in VBScript.. yes, we have been able to do this for years.


Sub Main
Set oConn = CreateObject("ADODB.Connection")
DoTransAction
Set oConn = nothing
End Sub

Sub DoTransAction()

On Error Resume Next

oConn.ConnectionString = "Provider=SLXOLEDB.1assword=ersist Security Info=True;User ID=lee;Initial Catalog=SLXEVAL62;Data Source=scarnie03;Extended Properties=""PORT=1707;LOG=ON"""

oConn.CursorLocation = adUseClient
oConn.Open

Dim bOk' as Boolean
bOk = true

' start a transaction
oConn.BeginTrans
MsgBox "Here"& Err
' create our opportunity record
Dim oRS_Opportunity ' as ADODB.Recordset

Set oRS_Opportunity = CreateObject("ADODB.Recordset")
oRS_Opportunity.LockType = adLockBatchOptimistic
oRS_Opportunity.CursorType = adOpenStatic

Dim sSQL ' as String
sSQL = "SELECT * FROM OPPORTUNITY WHERE 1=2"
oRS_Opportunity.Open sSQL, oConn

Dim sOpportunityKey ' as String
MsgBox "Here2"
oRS_Opportunity.AddNew
With oRS_Opportunity
sOpportunityKey = NewKeyFor("OPPORTUNITY")
.Fields("OPPORTUNITYID").Value = sOpportunityKey
.Fields("ACCOUNTID").Value = "A1" ' dummy
.Fields("SECCODEID").Value = "SYST00000001" ' everyone
.Fields("DESCRIPTION").Value = "My new opp"
End With

Dim oRS_OppProduct' as ADODB.Recordset

Set oRS_OppProduct = CreateObject("ADODB.Recordset")
oRS_OppProduct.LockType = adLockBatchOptimistic
oRS_OppProduct.CursorType = adOpenStatic

sSQL = "SELECT * FROM OPPORTUNITY_PRODUCT WHERE 1=0"
oRS_OppProduct.Open sSQL, oConn

Dim sOppProductKey ' as String
Dim iLoop' as Integer

For iLoop = 0 to 5
oRS_OppProduct.AddNew
With oRS_OppProduct
sOppProductKey = NewKeyFor("OPPORTUNITY_PRODUCT")
.Fields("OPPPRODUCTID").Value = sOppProductKey
.Fields("OPPORTUNITYID").Value = sOpportunityKey
.Fields("PRODUCTID").Value = "A" & iLoop ' dummy
.Fields("QUANTITY").Value = iLoop
.Fields("PRICE").Value = 12.50 * iLoop
End With
Next
MsgBox "Here3: " & Err
' post all records
oRS_OppProduct.UpdateBatch
If Err <> 0 Then
MsgBox "Error updating Opportunity Product: " & Err.number & ", Msg: " & Err.Description
bOk = false
End If

oRS_Opportunity.UpdateBatch
If Err <> 0 Then
MsgBox "Error updating Opportunity: " & Err.number & ", Msg: " & Err.Description
bOk = false
End If

' clean up code
Dim bResult' as Boolean
bResult = MsgBox("OpportunityID: " & sOpportunityKey, vbYesNo, "Commit transaction?")
If bResult = vbNo or not bOk Then
oConn.RollbackTrans
Else
oConn.CommitTrans
End If

oRS_Opportunity = nothing
oConn = nothing
End Sub


--
rjl
[Reply][Quote]
Vladimir
Posts: 93
 
Re: TransactionsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Oct 07 10:53 AM
Thanks!!!
[Reply][Quote]
Bob (RJ)Ledger
Posts: 1103
Top 10 forum poster: 1103 posts
 
Re: TransactionsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 Nov 07 6:34 AM
Welcome!

Transaction support is something that's been around for a long time (starting w/v6.x). We implemented it in a v6.2 project over 3 years ago in a "cloning" script. The clone script enabled cloning of over 15 tables of info in a custom entity. All of the tables had to be populated or we would not commit the transaction.

--
rjl
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 5/2/2024 9:44:11 PM