dbTalk Databases Forums  

access97 - wrk.beginTrans - how many statements can I execute beforethe commit ?

comp.databases.ms-access comp.databases.ms-access


Discuss access97 - wrk.beginTrans - how many statements can I execute beforethe commit ? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Roger
 
Posts: n/a

Default access97 - wrk.beginTrans - how many statements can I execute beforethe commit ? - 06-08-2010 , 03:22 PM






this is the vba,

Dim rs As DAO.Recordset
Dim wrk As DAO.Workspace

Set wrk = DBEngine.Workspaces(0)
Set db = wrk.Databases(0)
wrk.BeginTrans
On Error GoTo fRoll
strSql = "SELECT a.handoverId, a.lineNbr" & _
" FROM tblSlsDetail as a LEFT JOIN" & _
" baandb_ttdsls901228 as b ON a.handoverId =
b.t_hand" & _
" AND a.lineNbr = b.t_pono"
& _
" WHERE a.handoverId = " & lngHandoverId & _
" AND nz(b.t_ssta, 0) <> " & cProcessed
Set rs = db.OpenRecordset(strSql)
While (Not (rs.EOF))
db.execute "update ...."
db.execute "delete ...." (x 11)
rs.moveNext
wend

the rs.movenext fails, with "ODBC--call failed."
all the tables are linked to sql server
if I only execute 8 delete statements I have no problem, in
production, I can see 100s of statements
my temp folder is on a drive with GB's of spaces
is there a registry entry to increase the number of statements ?
or should I just use BEGIN TRANSACTION in sql server ?

Reply With Quote
  #2  
Old   
Rich P
 
Posts: n/a

Default Re: access97 - wrk.beginTrans - how many statements can I execute before the commit ? - 06-08-2010 , 04:35 PM






Historically, ODBC has been problematic for performing action queries
(Inserts/Updates/Deletes) on tables contained in a Sql Server DB from
Access. There are workarounds, but I find the easiest technique is to
use ADO when manipulating Sql Server objects from Access. Here is a
routine you could try out

note: you need to make a reference in a code module from Tools/Rerences
to

Microsoft ActiveX Data Objects 2.5 (or higher) Library

Sub ActionQueriesOnSqlServer()
Dim cmd As New ADODB.Command, j As Long

'--if you are using Windows authentication you can use
'--this connection string
'cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=yourServer;Database=YourDB;Trusted_Connecti on=Yes"

'--if you are using Sql Server authentication then use
'--this connection string
cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=YourServer;Database=YourDB;UID=steve;passwo rd=tiger;"

cmd.ActiveConnection.CursorLocation = adUseClient
cmd.CommandTimeout = 600
cmd.CommandType = adCmdText

cmd.CommandText = "Delete tblx Where ID = " & txtID
cmd.Execute j, , adExecuteNoRecords
Debug.Print j & " records Deleted"

cmd.CommandText = "Update tblx seled fld1 = 'test' Where ID = " &
txtID
cmd.Execute j, , adExecuteNoRecords
Debug.Print j & " records Updated"

cmd.ActiveConnection.Close

End Sub

Rich

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #3  
Old   
Roger
 
Posts: n/a

Default Re: access97 - wrk.beginTrans - how many statements can I executebefore the commit ? - 06-08-2010 , 05:09 PM



On Jun 8, 3:35*pm, Rich P <rpng... (AT) aol (DOT) com> wrote:
Quote:
Historically, ODBC has been problematic for performing action queries
(Inserts/Updates/Deletes) on tables contained in a Sql Server DB from
Access. *There are workarounds, but I find the easiest technique is to
use ADO when manipulating Sql Server objects from Access. *Here is a
routine you could try out

note: *you need to make a reference in a code module from Tools/Rerences
to

Microsoft ActiveX Data Objects 2.5 (or higher) Library

Sub ActionQueriesOnSqlServer()
* Dim cmd As New ADODB.Command, j As Long

* '--if you are using Windows authentication you can use
* '--this connection string
* 'cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=yourServer;Database=YourDB;Trusted_Connecti on=Yes"

* '--if you are using Sql Server authentication then use
* '--this connection string
* cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=YourServer;Database=YourDB;UID=steve;passwo rd=tiger;"

* cmd.ActiveConnection.CursorLocation = adUseClient
* cmd.CommandTimeout = 600
* cmd.CommandType = adCmdText

* cmd.CommandText = "Delete tblx Where ID = " & txtID
* cmd.Execute j, , adExecuteNoRecords
* Debug.Print j & " records Deleted"

* cmd.CommandText = "Update tblx seled fld1 = 'test' Where ID = "&
txtID
* cmd.Execute j, , adExecuteNoRecords
* Debug.Print j & " records Updated"

* cmd.ActiveConnection.Close

End Sub

Rich

*** Sent via Developersdexhttp://www.developersdex.com***
looks good, but I just remembered, some tables are on one sql server
and other tables are on a second sql server
and both need to be updated within the same transaction, can I do that
with ADO ?

Reply With Quote
  #4  
Old   
Tom van Stiphout
 
Posts: n/a

Default Re: access97 - wrk.beginTrans - how many statements can I execute before the commit ? - 06-08-2010 , 09:12 PM



On Tue, 8 Jun 2010 15:09:33 -0700 (PDT), Roger
<lesperancer (AT) natpro (DOT) com> wrote:

I would recommend you implement the transaction in a stored procedure.
You would create a Linked Server so the main SqlServer knows about the
other one, and you can write queries using a 4-part name:
select * from myLinkedServer.myDatabase.dbo.myTable

Implement your transaction in the stored procedure, and make sure
MSDTC = Distributed Transaction Coordinator is running, and you will
have the full protection of transactions.

-Tom.
Microsoft Access MVP




Quote:
On Jun 8, 3:35*pm, Rich P <rpng... (AT) aol (DOT) com> wrote:
Historically, ODBC has been problematic for performing action queries
(Inserts/Updates/Deletes) on tables contained in a Sql Server DB from
Access. *There are workarounds, but I find the easiest technique is to
use ADO when manipulating Sql Server objects from Access. *Here is a
routine you could try out

note: *you need to make a reference in a code module from Tools/Rerences
to

Microsoft ActiveX Data Objects 2.5 (or higher) Library

Sub ActionQueriesOnSqlServer()
* Dim cmd As New ADODB.Command, j As Long

* '--if you are using Windows authentication you can use
* '--this connection string
* 'cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=yourServer;Database=YourDB;Trusted_Connecti on=Yes"

* '--if you are using Sql Server authentication then use
* '--this connection string
* cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=YourServer;Database=YourDB;UID=steve;passwo rd=tiger;"

* cmd.ActiveConnection.CursorLocation = adUseClient
* cmd.CommandTimeout = 600
* cmd.CommandType = adCmdText

* cmd.CommandText = "Delete tblx Where ID = " & txtID
* cmd.Execute j, , adExecuteNoRecords
* Debug.Print j & " records Deleted"

* cmd.CommandText = "Update tblx seled fld1 = 'test' Where ID = " &
txtID
* cmd.Execute j, , adExecuteNoRecords
* Debug.Print j & " records Updated"

* cmd.ActiveConnection.Close

End Sub

Rich

*** Sent via Developersdexhttp://www.developersdex.com***

looks good, but I just remembered, some tables are on one sql server
and other tables are on a second sql server
and both need to be updated within the same transaction, can I do that
with ADO ?

Reply With Quote
  #5  
Old   
Roger
 
Posts: n/a

Default Re: access97 - wrk.beginTrans - how many statements can I executebefore the commit ? - 06-09-2010 , 03:47 PM



On Jun 8, 8:12*pm, Tom van Stiphout <tom7744.no.s... (AT) cox (DOT) net> wrote:
Quote:
On Tue, 8 Jun 2010 15:09:33 -0700 (PDT), Roger

lesperan... (AT) natpro (DOT) com> wrote:

I would recommend you implement the transaction in a stored procedure.
You would create a Linked Server so the main SqlServer knows about the
other one, and you can write queries using a 4-part name:
select * from myLinkedServer.myDatabase.dbo.myTable

Implement your transaction in the stored procedure, and make sure
MSDTC = Distributed Transaction Coordinator is running, and you will
have the full protection of transactions.

-Tom.
Microsoft Access MVP



On Jun 8, 3:35*pm, Rich P <rpng... (AT) aol (DOT) com> wrote:
Historically, ODBC has been problematic for performing action queries
(Inserts/Updates/Deletes) on tables contained in a Sql Server DB from
Access. *There are workarounds, but I find the easiest technique is to
use ADO when manipulating Sql Server objects from Access. *Here is a
routine you could try out

note: *you need to make a reference in a code module from Tools/Rerences
to

Microsoft ActiveX Data Objects 2.5 (or higher) Library

Sub ActionQueriesOnSqlServer()
* Dim cmd As New ADODB.Command, j As Long

* '--if you are using Windows authentication you can use
* '--this connection string
* 'cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=yourServer;Database=YourDB;Trusted_Connecti on=Yes"

* '--if you are using Sql Server authentication then use
* '--this connection string
* cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=YourServer;Database=YourDB;UID=steve;passwo rd=tiger;"

* cmd.ActiveConnection.CursorLocation = adUseClient
* cmd.CommandTimeout = 600
* cmd.CommandType = adCmdText

* cmd.CommandText = "Delete tblx Where ID = " & txtID
* cmd.Execute j, , adExecuteNoRecords
* Debug.Print j & " records Deleted"

* cmd.CommandText = "Update tblx seled fld1 = 'test' Where ID = " &
txtID
* cmd.Execute j, , adExecuteNoRecords
* Debug.Print j & " records Updated"

* cmd.ActiveConnection.Close

End Sub

Rich

*** Sent via Developersdexhttp://www.developersdex.com***

looks good, but I just remembered, some tables are on one sql server
and other tables are on a second sql server
and both need to be updated within the same transaction, can I do that
with ADO ?- Hide quoted text -

- Show quoted text -
thanks, but if I use ADO with this connection string
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
CurrentDb.name & ";"
cnn.CursorLocation = adUseClient
cnn.CommandTimeout = 600

I can work with the existing linked tables without worrying about
which server(s) are used, be it development or production

Reply With Quote
  #6  
Old   
jwither
 
Posts: n/a

Default Re: access97 - wrk.beginTrans - how many statements can I execute before the commit ? - 06-09-2010 , 09:09 PM



There is no limit on the number of statements you can execute.

The problems come from the way SQL Server locks tables
(which has changed since 1997), and on the way Access
caches connections (which probably is not your problem
with Access 97).

In any case, Jet DAO/SQL Server transactions are very much
broken in all later versions of Access/Jet against all later versions
of SQL Server, so this DAO/ODBC code is a dead end in
that respect.

(david)


"Roger" <lesperancer (AT) natpro (DOT) com> wrote

Quote:
this is the vba,

Dim rs As DAO.Recordset
Dim wrk As DAO.Workspace

Set wrk = DBEngine.Workspaces(0)
Set db = wrk.Databases(0)
wrk.BeginTrans
On Error GoTo fRoll
strSql = "SELECT a.handoverId, a.lineNbr" & _
" FROM tblSlsDetail as a LEFT JOIN" & _
" baandb_ttdsls901228 as b ON a.handoverId =
b.t_hand" & _
" AND a.lineNbr = b.t_pono"
& _
" WHERE a.handoverId = " & lngHandoverId & _
" AND nz(b.t_ssta, 0) <> " & cProcessed
Set rs = db.OpenRecordset(strSql)
While (Not (rs.EOF))
db.execute "update ...."
db.execute "delete ...." (x 11)
rs.moveNext
wend

the rs.movenext fails, with "ODBC--call failed."
all the tables are linked to sql server
if I only execute 8 delete statements I have no problem, in
production, I can see 100s of statements
my temp folder is on a drive with GB's of spaces
is there a registry entry to increase the number of statements ?
or should I just use BEGIN TRANSACTION in sql server ?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.