Click to See Complete Forum and Search --> : One more Bug!!!


Dr_Michael
September 16th, 1999, 03:35 AM
I have created a program which searches a database with some criteria and it displays the results in a data report. The problem is that although the .exe works well, the vb project crashes at the first(!) run on Kernel32.dll. So I can make any changes on the project because I cannot run it. I must compile it everytime and test the .exe. I think it's crazy!!! I tried to copy the code to another project, but with same results. By the way, I use VB6 with SP3.
All good ideas will be rated...

Michael Vlastos
Automation Engineer
Company Modus SA
Development Department

Lothar Haensler
September 16th, 1999, 03:43 AM
I'd try these approaches:
- try the same thing on another machine.
- search MSDN to see if there are any reported bugs with the Data report. I didn't find any!
- post the complete (!) code. Somebody might have time to try to reproduce that behavior.
- uninstall VB and install from scratch.
- reinstall Windows (and VB)

Dr_Michael
September 16th, 1999, 03:51 AM
REinstall windows is something difficult (timeless). Reinstalling vb is something I'll try soon. You asked about the whole code. It's very difficult because it comes accross with the database etc. Anyway, thanx for your try, I'll keep trying searching about new bugs. :-D


Michael Vlastos
Automation Engineer
Company Modus SA
Development Department

Chris Eastwood
September 16th, 1999, 04:01 AM
Hi

I've seen this kind of problem before - When I 'discovered' it in a large project, we were doing something similar to the following :

1. Create Object A locally
2. Create Object B from DLL
3. Pass Object A into Object B
4. Do some work with Object B (which works with Object A)
4. Set Object B = nothing

Now this worked fine in debug mode, but as soon as the program was run as an EXE we had all kinds of weird errors. The problem was that the DLL object B still had a reference to an Object in the EXE even though the reference to B had been cleared down.

This kind of circular reference can cause lot's of different GPF's and can be a nightmare to track down.

This might not be the cause of your problem, but I thought it might be interesting.


Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Dr_Michael
September 16th, 1999, 04:09 AM
Well, I found an error on my own code, and when I corrected it, it didn't crash again:
Wrong code:

If frmMain.blnNumberSearch = true then
dePrinting.rsPrintFields.Filter = " P_FLD0 = " & CStr(frmMain.intP_FLD0) & " AND P_FLD5 <= " & CStr(frmMain.lngNumberTo) & " AND P_FLD5 >= " & CStr(frmMain.lngNumberFrom) & ""
end if



Correct code:

If frmMain.blnNumberSearch = true then
dePrinting.rsPrintFields.Filter = " P_FLD0 = " & CStr(frmMain.intP_FLD0) & " AND P_FLD5 <= " & CStr(frmMain.lngNumberTo) & " AND P_FLD5 >= " & CStr(frmMain.lngNumberFrom) & "'"
end if



But is this a reason for vb to crash in kernel32.dll? And if we suppose that it corrected the crash, another problem exists yet:
On first run the report is blank and on second it is correct. However, the exe still works well!!!


Michael Vlastos
Automation Engineer
Company Modus SA
Development Department

Dr_Michael
September 16th, 1999, 04:28 AM
It crashed again after the correction I made, so it is definetely a bug of reports. :'-(

Michael Vlastos
Automation Engineer
Company Modus SA
Development Department

Dr_Michael
September 16th, 1999, 05:44 AM
Well, here is the bug:
Wrong code:

private Sub DataReport_Terminate()
End
End Sub



Correct code:

private Sub DataReport_QueryClose(Cancel as Integer, CloseMode as Integer)
End
End Sub




Question:
Is it my fault or VB's ???

Michael Vlastos
Automation Engineer
Company Modus SA
Development Department

Lothar Haensler
September 16th, 1999, 06:12 AM
IMHO the IDE should never crash, no matter what you do. I'd accepts crashes whenever you pass addresses to SDK functions (as in subclassing), but not with regular VB syntax.

OTOH, I would never End my program when a report ends or a report window is terminated. But that's a different story.

Chris Eastwood
September 16th, 1999, 06:42 AM
I'd say it's your bug - the 'End' statement will terminate the program there and then.

If you think about it, this is what's happening from the DataReports point of view :

1. Do some processing
2. Tell the container that we're finished
3. Do some final checking/cleaning up (usercontrol_terminate etc)

Meanwhile, VB is expecting to issue a 'Terminate' event to kill off the control when it's no longer used. Of course it can't because you've effectively killed the program without it being able to tidy up it's own memory / address spaces.

Memory leaks anyone ?

I think the moral here is (and haven't we been down this route before?), never use the END statement in your programs. Make sure all your forms and objects are unloaded and your program will end gracefully.



Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Dr_Michael
September 16th, 1999, 07:43 AM
... why on the first run the report is blank?
I have only labels and text boxes on the report. What do you suggest to do when I want to close the program?


Michael Vlastos
Automation Engineer
Company Modus SA
Development Department

Dr_Michael
September 16th, 1999, 07:44 AM
I want my program to terminate when the report is closed. How else can I manage it?

Michael Vlastos
Automation Engineer
Company Modus SA
Development Department

Chris Eastwood
September 16th, 1999, 07:54 AM
>... why on the first run the report is blank?

I don't know about that ....

>What do you suggest to do when I want to close the program?

If you only have the one form and that's setup as the start-up object, why not have a simple 'Unload Me' command in the 'DataReport_QueryClose' or 'DataReport_Terminate' events ?




Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb