Solved

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

Posted on 2002-05-29
7
151 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
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

786 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