Solved

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

Posted on 2002-05-29
7
149 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

20 Experts available now in Live!

Get 1:1 Help Now