Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21243

vb6 and timeout error when moveNext on last selection

$
0
0
Hello;

I am having problems with VB6 and SQL Server 2005 and 2008. I am working with an application, built by a vendor but I have put a lot of work into myself. It is an archive and retrieve app that deletes records from the prod db and inserts the same rows into the archive db. In most cases, the app does what it is supposed to. Every now and then, a little too often for my liking, I get an ODBC Timeout error ([Microsoft][ODBC SQL Server Driver]Query timeout expired).

I have tried to increase the timeout (*.sCommand.CommandTimeout = 120 and even 0) to no avail and I have changed the provider from msdasql to sqloledb. I have narrowed the error to a moveNext on a recordSet but the error I get states that it is a timeout.

Here is a snippet of code where it fails;

Code:

Do While rsNames.EOF = False
        DoEvents
        'select the data
        If bArchive = True Then
                bFlag = CreateSelectSQL(cProd.sCommand, Right$(rsNames!Tbname, Len(rsNames!Tbname) - 4), sPolicyNumber, iPortfolioSet, asPolicyDateTimes, asOccurNumbers, asAccountSets, asAuditIds, bArchive)
                cProd.sCommand.CommandTimeout = 0
                Set rsSelection = ExecuteCommand(cProd)
        Else
                bFlag = CreateSelectSQL(cArchive.sCommand, rsNames!Tbname, sPolicyNumber, iPortfolioSet, asPolicyDateTimes, asOccurNumbers, asAccountSets, asAuditIds, bArchive)
                cProd.sCommand.CommandTimeout = 0
                Set rsSelection = ExecuteCommand(cArchive) 'cArchive.sCommand.Execute
        End If
       
        If rsSelection.EOF = False Then 'got a record to move
                If bFlag = False Then      'select process failed
                        Exit Do
                Else                                                            rsSelection.MoveFirst
                        If bArchive Then
                                bFlag = CreateDeleteSQL(sDelete, Right(rsNames!Tbname, Len(rsNames!Tbname) - 4), sPolicyNumber, iPortfolioSet, asPolicyDateTimes, asOccurNumbers, asAccountSets, asAuditIds)
                        Else
                                bFlag = CreateDeleteSQL(sDelete, rsNames!Tbname, sPolicyNumber, iPortfolioSet, asPolicyDateTimes, asOccurNumbers, asAccountSets, asAuditIds)
                        End If
                       
                        If bFlag = False Then  'deletion process failed
                        Else 'continue
                                ...
                        End If
                       
                        'Walk thru the rsSelection and test the moveNext

                        Do While rsSelection.EOF = False
                                DoEvents
                               
                                If bArchive Then
                                        bFlag = CreateInsertSQL(rsNames!Tbname, sInsert, sOccurNumber, sLossDate, sArchiveOccurrenceSummary, 0)
                                Else
                                        bFlag = CreateInsertSQL(Right$(rsNames!Tbname, Len(rsNames!Tbname) - 4), sInsert, sOccurNumber, sLossDate, sArchiveOccurrenceSummary, 1)
                                End If
                               
                                If bFlag = False Then
                                        AppendToLog "Failure:  Unable to create the insert statement for " & sPolicyNumber & "-" & iPortfolioSet & " with an expiration date of " + sPolExpDate + "."
                                        Exit Do
                                Else
                                        ...
                                End If
                                If rsSelection.EOF = False Then
                                        rsSelection.MoveNext
                                End If
                        Loop    'rsSelection.EOF = False
                End If  'bFlag = False
        End If  'rsSelection.EOF = False
        rsNames.MoveNext
Loop    'rsNames.EOF = False

Even though I am testing the reSelection.EOF = false before I execute the MoveNext when I step over the MoveNext the program errors out and all execution stops.

I have added timings to the log file and some queries are running 488.829 seconds long so I am pretty sure that the query is successful.

Does anyone have any ideas/suggestions?

kuldip

Viewing all articles
Browse latest Browse all 21243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>