Link to home
Start Free TrialLog in
Avatar of DLockwood
DLockwood

asked on

Terminate unexpectedly - no trace or reason - URGENT

I have a VB application written in VB 6.0 and using ADO 2.7 to connect to a SQL Server 2000 database.

I have error handling set and it normally reports all my errors just fine. Now my program has begun terminating unexpectedly and there is no repsonse from the error object.

So, I went into tools > General> Errors> and turned on Break on all errors.

When I repeated the action that causes the problem, the application terminated again and there was no break in the code.

This is a program that I inherited and am stuck working on. It is far too large to step through it and I have no idea how to find what is causing it to terminate.

Any ideas?
Avatar of Jacamar
Jacamar

There must be some line in the code that is ending the program, and it isn't an error.  I would search for key words such as

Unload
QueryUnload
Terminate

And check what it is there for.

If you say you've inherited it, then this statement could've been used for test purposes.

Good luck on your hunt.

Jacamar
what is the action you do to duplicate the problem?
a control click, keypress or whatever?

Is it possible to determine which sub this might be in?

Maybe you can narrow down the search to a certain controls events and look in those subs?
agree with Jacamar ...

also look for keyword "END" and "KERNEL32" - as one can call the API to terminate an application.
Avatar of DLockwood

ASKER

Ok,

I have been searching my b*** off.
No Unload.
No QueryUnload.
No Terminate
No End
No Kernel32.

Got any other ideas?
Ok,

I have been searching my b*** off.
No Unload.
No QueryUnload.
No Terminate
No End
No Kernel32.

Got any other ideas?
Check this stuff....

1. does the project make use of API calls?  Any hooks, or subclassing?  Search your entire project for 'Declare'.  If you find this then your prolly using API calls.  If so, which ones?

2. Go to Project>Properties, click on the 'Compile' tab, and click on the 'Advanced Optimizations...'.  Are any of the check boxes checked?  If they are then uncheck all of them, and try again.

I know this is absolutley mad, but humour me. (I had a similar problem and I'm not convinced of how it was resolved.)
Are you calling any stored procs which begin with sp_ ... for example, sp_get_data ???

If so, try changing them to proc_ or something else.

bukko

...or, are you using client-side cursors?
Try changing to server side.

bukko
ASKER CERTIFIED SOLUTION
Avatar of JRCSystems
JRCSystems
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
good suggestion jrc...i was going to suggest something very similar
JRC - Thanks for the suggestion. Though simple it may seem, I had not thought of it. It worked just like you said and led me to the bad line of code.

FYI to all participating, the problem was an ADO issue in which a recordset was being to set to an update query. If the program tried to hit that DB connection again, it just caused the VB executable to stop running with no hint of why. If I stepped through the code it would not reproduce the error, becuase, evidently, enough time had gone by for SQL Server to rectify the problem and straighten itself out.

Anyway, I am now running the update statement using the Execute object and everything is running great.

Thanks to all who helped!
You should create a logger class.  This makes it much easier to keep track of things.  Especially when you have to find errors on someones machine that you just don't have access to.
Here is the Class module I use.  It could use some refining, and cleaning up, but its very handy.

'******************************
' Description: Creates/Appends to a log file with in the current working directory call App.EXEName & ".log"
' USAGE:
'        Dim log as clsLog
'        Set log = New clsLog
'        used to start a new section in the logfile
'        log.Heading("Heading Title")
'        used to log a new message, 2 boolean parameters
'        are used as follows
'        Param2 tells Add to put a vbCRLF to the end of the
'        message
'        Param3 tells Add to put a timestamp at the
'        beginning of the line with the message.
'        Both Param2 and Param3 default to True is you
'        do not specify them
'        log.Add("Message to add",True, True)
'        used to log errors, i generally put this in my
'        error handlers.  Writes the Err Object info to the
'        log file along with String passed and timestamp
'        log.Error("Procedure Name")
'        
'        A suggestion for improvements, move the Open File
'        command into the Class_Initialize() and add a
'        Close File# to Class_Terminate()
'        Remove all references to Open and Close except in
'        the Initialize and Terminate events
'******************************
Option Explicit
Private strFilename As String

Public Property Get FileName() As String
    FileName = strFilename
End Property

Public Function Error(Proc As String)
    If Err.Number = 0 Then Exit Function
           
    ' Open .log file and log the error
    Open App.Path & "\" & strFilename For Append As #1
    Print #1, _
    " " & vbCrLf & _
    "     Source = " & Err.Source & vbCrLf & _
    "  Procedure = " & Proc & vbCrLf & _
    "     Number = " & Err.Number & vbCrLf & _
    "Description = " & Err.Description & vbCrLf & _
    "       Time = " & Now & vbCrLf & _
    " " & vbCrLf & _
    "--------------------------------------------------------------------------"
    Close #1
End Function
Public Function Add(strMsg As String, Optional NewLine As Boolean = True, Optional TimeStamp As Boolean = True)
    ' Open .log file and log the message
    Open App.Path & "\" & strFilename For Append As #1
   
    ' Timestamp?
    If TimeStamp Then Print #1, "[" & Now & "] ";
   
    ' Write the message
    Print #1, strMsg;
   
    ' New line?
    If NewLine Then Print #1, vbCrLf;
   
    Close #1
End Function
Public Function PrintLine()
    ' Open .log file and log the message
    Open App.Path & "\" & strFilename For Append As #1
    ' Write the line
    Print #1, "--------------------------------------------------------------------------------------------------------" & vbCrLf;
   
    Close #1
   
End Function
Public Function Heading(Title As String)
    ' Open .log file and log the message
    Open App.Path & "\" & strFilename For Append As #1
    ' Write the line
    Print #1, String(Len(Title) + 4, "*") & vbCrLf;
    Print #1, "* " & Title & " *" & vbCrLf;
    Print #1, String(Len(Title) + 4, "*") & vbCrLf;
   
    Close #1
   
End Function

Private Sub Class_Initialize()
    strFilename = App.EXEName & ".log"
End Sub