Solved

SQL Server 7 stored procedure won't time out using command object

Posted on 2002-05-29
7
155 Views
Last Modified: 2010-05-02
I am baffled on this one...

We have a VB 6 component running in MTS.  I have set the commandtimeout on the command to be 90 seconds.  Occasionally on one stored procedure call, we get a timeout error, which is fine (this stored procedure can take awhile to run).  

However, sometimes the stored procedure NEVER times out.  Our custom logging shows it will hang inside the stored procedure call indefinitely.  It will NOT stop by itself, I have to kill the process and shut down the package in MTS.

When this happens, the CPU percentage on the application server running the component (not the database server) goes up to 100% until I kill the task/shut down the package.

I don't think this is a data or stored proc problem.  The error that gets logged in the event viewer of Windows NT is "One or more errors occurred during processing of command."  The source on the error is not SQL Server, it is the component.  Also, this stored procedure gets called 2000+ times per day without incident.

Any ideas?
0
Comment
Question by:bfassler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:crw030
ID: 7043136
Do you log the stored procedure parameters that are being passed each time?  If so can you verify via a manual sp call they parameters supplied are not the problem?

One thing I have seen with SQL stored procedure calls from VB is that sometimes VB perceives there to be multiple recordsets being returned by the procedure (which is frustrating because you don't see them in Query Analyzer).  

Maybe it's just something I'm doing, but I have resorted to checking my resultant recordset to see if it contains multiple recordsets (using Set rs2=rs1.NextRecordset)
(Probably a better way available from one of the VB gurus)
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 7043141
You might ask a 0 point question in the MS-SQL Experts area under Databases and include a link to this question.

mlmcc
0
 

Author Comment

by:bfassler
ID: 7043147
I do log the parameters.  It is not the parameters.  As soon as I start the program back up, the stored procedure runs fine (for the same parameters that were a problem before).  Also, a manual call works as well.

There is no recordset returned by the stored procedure.  Basically we just run the execute method on the command object.  Pretty simple.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:crw030
ID: 7043164
Can you post a code snippet of the Execute call and the code following it until the component would normally exit?

Could you write an event indicating the Execute call finsihed?
0
 

Author Comment

by:bfassler
ID: 7044415
BEGIN CODE

On Error Resume Next
cmd.Execute
   
' If we error out of Stored Procedure due to a timeout, then make sure to rollback any transaction that was started.

    If Err.Number <> 0 Then
        sOrigError = Err.Description
        sOrigErrSource = Err.Source
        If InStr(1, UCase(Err.Description), "TIMEOUT") > 0 Then
            Set cmd1 = New ADODB.Command
            Set cmd1.ActiveConnection = cmd.ActiveConnection
            cmd1.CommandType = adCmdStoredProc
            cmd1.CommandText = "AE_End_Transaction"
            cmd1.Execute
            Set cmd1 = Nothing
        End If
        On Error GoTo errhandler
        Err.Raise vbObjectError + 2000, sOrigErrSource, sOrigError
    End If
   
    On Error GoTo errhandler
         
    Set cmd.ActiveConnection = Nothing
   
    Set cmd = Nothing
 
    If bLog Then Call log(spName, "  end", False, param())

END CODE

We never log the last line of code, where the stored procedure ends.  This large stored procedure is a vendor stored procedure -- it is very long and contains many nested transactions.  We WERE having a problem where we were timing out within a transaction and later, when the connection was shut down, it would roll back MANY transactions.  That's what the middle code does.  Maybe I need to put some logging in there and see if we're getting stuck in there.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7851276
Hi bfassler,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

bfassler, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7912867
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question