473,668 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access2003 - sql server 2005, db.execute times out updating sqlserver data

This is the vba code

Set db = CurrentDb
On error goto fErr
…. loop
strSql = "UPDATE tblInvAnalysisW hse" & _
" SET ltDeviation = " & Sqr(dblError /
intPeriods) & _
" WHERE item = '" & Trim(strItem) & "'" & _
" AND location = " & intLocation
dblCount = dblCount + 1
db.Execute strSql, dbFailOnError

fErr:
stop
resume next

db.execute always fails after 1246 iterations, with
- [Microsoft][ODBC SQL Server Driver]Timeout
expired ,ODBC.Database ,0
- ODBC--update on a linked table 'tblInvAnalysis Whse'
failed. ,DAO.Database ,3157
'tblInvAnalysis Whse’ has 107,000+ records, and is a linked sql server
table
Columns item & location are indexed

Strsql on failure is
UPDATE tblInvAnalysisW hse
SET ltDeviation = 9
WHERE item = 'P103 L25348' AND location = 21

If I try to execute the UPDATE statement in sql server, it never
completes (8 mins and running)
There’s nothing in the sql server logs
And my process only has 20 object locks
Until I 'stop' running the ms-access function, and then the sql server
statement completes immediately
Of course, all the locks are gone

so the problem has to do with locks

So what do I need to do, in a vba loop, to free up my sql server locks
after each update statement ?
create a transaction ?
create a passthrough query to do the update ?


Oct 27 '08 #1
7 3448
This is a limitation with Access and ODBC against a sql server. You
would be way better off using ADO to perform this operation - you get
way more bandwidth and can circumvent the record locking issue more
effectively because ADO does not hold the connection open continuously
like ODBC and you can set a timeout with ADO.

A more ideal solution would be to perform this type of operation with
ADO.Net -- but that is .Net country.

Classic ADO (ADO) was specifically designed for interfacing com based
apps (VB6, Access, Excel) with sql server (and Oracle, DB2).

My recommendation would be to use ADO for this operation. There may be
some tweakage you could do to make the ODBC setup work better - I don't
know it - but it is tweakage. ADO is straight forward - simple. Here
is a sample:

----------------------------------------

'--make a reference to Microsoft ActiveX Data Object 2.5 (or higher)
library

Dim cmd As New ADODB.Command
cmd.ActiveConne ction = "Provider=SQLOL EDB; Data
Source=yourServ er;Database=You rDB;Trusted_Con nection=Yes"
cmd.ActiveConne ction.CursorLoc ation = adUseClient
cmd.CommandTime out = 600
cmd.CommandType = adCmdText

Do While Not RS.EOF
cmd.CommandText = "Update tblz Set fld5 = ' & rs(1) & ' Where fld1 =
'ddd'"
cmd.Execute
Loop

----------------------------------------

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Oct 27 '08 #2
On Oct 27, 4:57*pm, Rich P <rpng...@aol.co mwrote:
This is a limitation with Access and ODBC against a sql server. *You
would be way better off using ADO to perform this operation - you get
way more bandwidth and can circumvent the record locking issue more
effectively because ADO does not hold the connection open continuously
like ODBC and you can set a timeout with ADO.

A more ideal solution would be to perform this type of operation with
ADO.Net -- but that is .Net country.

Classic ADO (ADO) was specifically designed for interfacing com based
apps (VB6, Access, Excel) with sql server (and Oracle, DB2). *

My recommendation would be to use ADO for this operation. *There may be
some tweakage you could do to make the ODBC setup work better - I don't
know it - but it is tweakage. *ADO is straight forward - simple. *Here
is a sample:

----------------------------------------

'--make a reference to Microsoft ActiveX Data Object 2.5 (or higher)
library

Dim cmd As New ADODB.Command
cmd.ActiveConne ction = "Provider=SQLOL EDB; Data
Source=yourServ er;Database=You rDB;Trusted_Con nection=Yes"
cmd.ActiveConne ction.CursorLoc ation = adUseClient
cmd.CommandTime out = 600
cmd.CommandType = adCmdText

Do While Not RS.EOF
* cmd.CommandText = "Update tblz Set fld5 = ' & rs(1) & ' Where fld1 =
'ddd'"
* *cmd.Execute
Loop

----------------------------------------

Rich

*** Sent via Developersdexht tp://www.developersd ex.com***
ok, I tried the ado method proposed, and I get the same error after
1246 'updates'
I also tried, connecting before each update and disconnecting
afterwards

Dim cmd As ADODB.Command

Do While Not RS.EOF
set cmd = new adodb.command
cmd.ActiveConne ction = "Provider=SQLOL EDB; Data
Source=yourServ er;Database=You rDB;Trusted_Con nection=Yes"
cmd.ActiveConne ction.CursorLoc ation = adUseClient
cmd.CommandTime out = 600
cmd.CommandType = adCmdText
cmd.CommandText = "Update tblz Set fld5 = ' & rs(1) & ' Where fld1
=
'ddd'"
cmd.Execute
set cmd = nothing
Loop

and it still fails after 1269 passes...

what am I missing ?
ps. I tried both encapsulating the updates in a 'transaction' as well
as using a passthrough query... same problem, same number of passes
Oct 28 '08 #3
On Oct 28, 12:58*pm, Roger <lesperan...@na tpro.comwrote:
On Oct 27, 4:57*pm, Rich P <rpng...@aol.co mwrote:


This is a limitation with Access and ODBC against a sql server. *You
would be way better off using ADO to perform this operation - you get
way more bandwidth and can circumvent the record locking issue more
effectively because ADO does not hold the connection open continuously
like ODBC and you can set a timeout with ADO.
A more ideal solution would be to perform this type of operation with
ADO.Net -- but that is .Net country.
Classic ADO (ADO) was specifically designed for interfacing com based
apps (VB6, Access, Excel) with sql server (and Oracle, DB2). *
My recommendation would be to use ADO for this operation. *There may be
some tweakage you could do to make the ODBC setup work better - I don't
know it - but it is tweakage. *ADO is straight forward - simple. *Here
is a sample:
----------------------------------------
'--make a reference to Microsoft ActiveX Data Object 2.5 (or higher)
library
Dim cmd As New ADODB.Command
cmd.ActiveConne ction = "Provider=SQLOL EDB; Data
Source=yourServ er;Database=You rDB;Trusted_Con nection=Yes"
cmd.ActiveConne ction.CursorLoc ation = adUseClient
cmd.CommandTime out = 600
cmd.CommandType = adCmdText
Do While Not RS.EOF
* cmd.CommandText = "Update tblz Set fld5 = ' & rs(1) & ' Where fld1 =
'ddd'"
* *cmd.Execute
Loop
----------------------------------------
Rich
*** Sent via Developersdexht tp://www.developersd ex.com***

ok, I tried the ado method proposed, and I get the same error after
1246 'updates'
I also tried, connecting before each update and disconnecting
afterwards

Dim cmd As ADODB.Command

*Do While Not RS.EOF
* *set cmd = new adodb.command
* *cmd.ActiveConn ection = "Provider=SQLOL EDB; Data
* *Source=yourSer ver;Database=Yo urDB;Trusted_Co nnection=Yes"
* *cmd.ActiveConn ection.CursorLo cation = adUseClient
* *cmd.CommandTim eout = 600
* *cmd.CommandTyp e = adCmdText
* *cmd.CommandTex t = "Update tblz Set fld5 = ' & rs(1) & ' Where fld1
=
*'ddd'"
* * cmd.Execute
* * set cmd = nothing
*Loop

and it still fails after 1269 passes...

what am I missing ?

ps. *I tried both encapsulating the updates in a 'transaction' as well
as using a passthrough query... same problem, same number of passes- Hidequoted text -

- Show quoted text -
went back to using a passthrough query but changed the function to
populate the passthrough with 500 update statements at a time before
executing it

and it fails with timeout on the third execute (1001 - 1500th
updates)..
so why can't sql server process more than 1269 updates
and why does 'stopping' code execution allow the passthrough to then
execute successfully ?
Oct 29 '08 #4
Hi Roger,

Note: I don't think the problem was with ODBC after all. The problem
may be with the data at a certain point in your procedure.

Try this: go back to the ADO loop (or ODBC - don't think it matters at
this point) - add a loop counter so that you know at what iteration of
the loop you have the problem. I think the problem is with the
parameter(s) you are passing or the row you are trying to update at that
iteration. You want to isolate that row (or params you are passing).
Once you have clearly identified that row or param - use a where clause
to exclude it and see if your procedure runs.

Another thought would be to try running your procedure from a starting
point after the point where you are encountering your problem. If the
procedure runs OK after that point - then there is a problem with the
data - most likely some null/nulling issue where the query is trying to
guess what to do but there is nothing there for it to do anything with
at that point (I will take a guess that maybe at the point whwere the
timeout occurs the problem may be in your where clause - not accounting
for somethign at some row).
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Oct 29 '08 #5
On Oct 29, 9:18*am, Rich P <rpng...@aol.co mwrote:
Hi Roger,

Note: *I don't think the problem was with ODBC after all. *The problem
may be with the data at a certain point in your procedure.

Try this: *go back to the ADO loop (or ODBC - don't think it matters at
this point) - add a loop counter so that you know at what iteration of
the loop you have the problem. *I think the problem is with the
parameter(s) you are passing or the row you are trying to update at that
iteration. *You want to isolate that row (or params you are passing).
Once you have clearly identified that row or param - use a where clause
to exclude it and see if your procedure runs. *

Another thought would be to try running your procedure from a starting
point after the point where you are encountering your problem. *If the
procedure runs OK after that point - then there is a problem with the
data - most likely some null/nulling issue where the query is trying to
guess what to do but there is nothing there for it to do anything with
at that point (I will take a guess that maybe at the point whwere the
timeout occurs the problem may be in your where clause - not accounting
for somethign at some row).

Rich

*** Sent via Developersdexht tp://www.developersd ex.com***
since I was creating a passthrough query, with 500 update statements
and it failed on the 3rd pass, I copied all 1500 update queries into
one sql server statement

it runs without a problem

since I already had a counter has you suggested, and it indicates that
the failure occurs on the 1269th iteration, and since sql server can
process all 1500 statements, I'm guess the problem is elsewhere

but the same function works fine in access97, accessing the same sql
server 2005 tables....

so I'm going to try an adodb recordset instead of a dao recordset in
this loop
Do While Not RS.EOF
cmd.CommandText = "Update tblz Set fld5 = ' & rs(1) & ' Where fld1
=
'ddd'"
cmd.Execute
Loop
Oct 29 '08 #6
On Oct 29, 9:44*am, Roger <lesperan...@na tpro.comwrote:
On Oct 29, 9:18*am, Rich P <rpng...@aol.co mwrote:


Hi Roger,
Note: *I don't think the problem was with ODBC after all. *The problem
may be with the data at a certain point in your procedure.
Try this: *go back to the ADO loop (or ODBC - don't think it matters at
this point) - add a loop counter so that you know at what iteration of
the loop you have the problem. *I think the problem is with the
parameter(s) you are passing or the row you are trying to update at that
iteration. *You want to isolate that row (or params you are passing).
Once you have clearly identified that row or param - use a where clause
to exclude it and see if your procedure runs. *
Another thought would be to try running your procedure from a starting
point after the point where you are encountering your problem. *If the
procedure runs OK after that point - then there is a problem with the
data - most likely some null/nulling issue where the query is trying to
guess what to do but there is nothing there for it to do anything with
at that point (I will take a guess that maybe at the point whwere the
timeout occurs the problem may be in your where clause - not accounting
for somethign at some row).
Rich
*** Sent via Developersdexht tp://www.developersd ex.com***

since I was creating a passthrough query, with 500 update statements
and it failed on the 3rd pass, I copied all 1500 update queries into
one sql server statement

it runs without a problem

since I already had a counter has you suggested, and it indicates that
the failure occurs on the 1269th iteration, and since sql server can
process all 1500 statements, I'm guess the problem is elsewhere

but the same function works fine in access97, accessing the same sql
server 2005 tables....

so I'm going to try an adodb recordset instead of a dao recordset in
this loop
Do While Not RS.EOF
* cmd.CommandText = "Update tblz Set fld5 = ' & rs(1) & ' Where fld1
=
'ddd'"
* *cmd.Execute
Loop- Hide quoted text -

- Show quoted text -
changing RS to an ADODB recordset solves the problem, I'm just not
sure why
Oct 29 '08 #7
Not to knock ODBC, but I have consistently had less problems and way
more performance using ADO (ADODB) against the sql server from Access
(and Excel). But if you will be interfacing with sql server on a
consistent basis (like from now forward) I would recommend stepping up
to ADO.Net. ADODB supercedes ODBC, and ADO.Net supercedes ADODB. The
improvements between ADO.Net and ADODB is more substantial than the
improvements between ADODB and ODBC. To Date: nothing commercial can
outperform ADO.Net against any current RDBMS (Sql server, Oracle of the
ones I know of).

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Oct 29 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4120
by: AlessanBar | last post by:
Hello Friends !! I have a strange problem, and I need to know what would be the source of this. I have a laptop computer with the following configuration: Pentium III Brand : Toshiba Speed : 500 Mhz RAM : 192 MB Hard Disk : 6 GB
6
3784
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for one day): \\FFDS24\ASP.NET Applications(_LM_W3SVC_1_Root_ATV2004)\Errors During Execution: 7 \\FFDS24\ASP.NET Apps v1.1.4322(_LM_W3SVC_1_Root_ATV2004)\Compilations
9
3306
by: billmiami2 | last post by:
I was playing around with the new SQL 2005 CLR functionality and remembered this discussion that I had with Erland Sommarskog concerning performance of scalar UDFs some time ago (See "Calling sp_oa* in function" in this newsgroup). In that discussion, Erland made the following comment about UDFs in SQL 2005: >>The good news is that in SQL 2005, Microsoft has addressed several of these issues, and the cost of a UDF is not as severe...
10
2096
by: amjad | last post by:
how to connection sql server table with aspx like pulling data from table to grid view.... simple example to start .... thanks
2
3027
by: R.A.M. | last post by:
Hello, I am learning .NET 2.0. I need to write an assembly to be added to SQL Server 2005 database DemoSQLServer, with stored procedures. According to one of my books I wrote (Demo.cs): using System; using System.Collections.Generic; using System.Text; using System.Data.Sql; using System.Data.SqlServer;
2
6948
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
2
10858
by: thersitz | last post by:
Hi, I have VStudio2005, SQLServer 2005 dev edition loaded on a windowsXP Pro machine. I installed it ok. I just attempted to load the Personal Web Site Starter Kit (I downloaded off Microsoft's site) to use with VStudio 2005 -- Installing it from the MS site failed without any error messages. When I used VSTudio to open, it loaded ok, but when I went to view the default.aspx page I got this error:
12
2243
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my office. The original code's backend is using the SQL Server 2000 and I am testing to use it on the Express edition. And I run into the following problem.
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8889
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8652
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.