Solved

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

Posted on 2002-05-29
7
146 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now