?
Solved

Terminate unexpectedly - no trace or reason - URGENT

Posted on 2003-03-03
12
Medium Priority
?
236 Views
Last Modified: 2012-05-04
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?
0
Comment
Question by:DLockwood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +5
12 Comments
 
LVL 2

Expert Comment

by:Jacamar
ID: 8059745
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
0
 
LVL 3

Expert Comment

by:DeAn
ID: 8059801
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?
0
 
LVL 4

Expert Comment

by:RanaHossain
ID: 8060110
agree with Jacamar ...

also look for keyword "END" and "KERNEL32" - as one can call the API to terminate an application.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:DLockwood
ID: 8060266
Ok,

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

Got any other ideas?
0
 

Author Comment

by:DLockwood
ID: 8060503
Ok,

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

Got any other ideas?
0
 
LVL 3

Expert Comment

by:Da_Weasel
ID: 8060706
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.
0
 
LVL 8

Expert Comment

by:bukko
ID: 8060771

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
0
 
LVL 8

Expert Comment

by:bukko
ID: 8060776

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

bukko
0
 
LVL 4

Accepted Solution

by:
JRCSystems earned 1200 total points
ID: 8061226
How to solve the unsolvable:

Create a trace file. At the TOP/uppermost line of each function and/or subroutine, print that function/subroutine name into a file, along with date/time information.


When you program ends abruptly, it will not delete the file. You can now trace its steps to see where it is dying.

Once you find that out (by examining the last routine dumped into the log), spinkle MSGBOXes into that routine and you will soon see the culprit code corrupting the system.

This IS work... but IT WILL WORK. GUARANTEED.
0
 
LVL 2

Expert Comment

by:Hossy
ID: 8062252
good suggestion jrc...i was going to suggest something very similar
0
 

Author Comment

by:DLockwood
ID: 8064743
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!
0
 
LVL 3

Expert Comment

by:Da_Weasel
ID: 8065789
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…
Suggested Courses
Course of the Month10 days, left to enroll

762 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