Solved

Trapping errors from Business Tier DLL

Posted on 2001-06-21
11
317 Views
Last Modified: 2010-05-02
I develop a three tiers application in VB6, client-server architecture.
The User interface tier is a VB6 EXE project. The Business tier is a VB6 Active X COM project (DLL) that has some classes.
The data are introduced by a VB form of User interface tier, but is validated in Business tier?s property functions.
When a data isn?t OK (wrong data), I have to write a message on the screen and retry the data input flow in the User interface tier input procedure.
My problem is:
How can Business object tier procedure to tell User interface tier procedure that there are an error (and it have to retry the data input).
I have try to use err.Raise in Business tier procedure, but User interface tier procedure isn?t interrupted by an error:
On Error goto err:
     Object.member=value     ?call the property function of member of object.
     ?The property contains err.Raise
     Msgbox ?is ok?
     Exit sub
Err:
     Msgbox ?I was interrupted by an error?
     End sub
I see ?is ok?.
Is this unpleasant situation related to the following sentences from MSDN Library Visual Studio 6.0 help: ?System errors during calls to Windows DLL do not raise exceptions and cannot by trapped with Visual Basic Error trapping? ?
How can I trap validation errors from Business object tier procedure?

0
Comment
Question by:redundguy
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
A simple Err.Raise will not be enough, i must contain at least a non-zero error number:
Err.Raise 994349
Additionally, you can supply the Description, source aso

The info you read from the Windows DLL is different: the code in there will not raise exceptions, but give you return codes, which indicate if the code has executed successfully or not.

Cheers
0
 
LVL 1

Expert Comment

by:barendb
Comment Utility
redundguy,

You'll have to use a method in the DLL part to pass the data to the DLL, validate it and return a value to the EXE if data was accepted or not, you can even return a UDT with the error value (if any) and the value that returned the error.

Hope this helps.

Barend
0
 
LVL 22

Expert Comment

by:CJ_S
Comment Utility
Should work properly IMHO.

Err.Raise vbObjectError + 512

Regards,
CJ

(ps. if you write something in word anc copy / paste it, the single quote will be changed the a question mark, as you can see in your question :-)..)
0
 
LVL 15

Expert Comment

by:ameba
Comment Utility
Last 10 Grades Given:  A B C    :-(

Before raising the error, *always* include "On Error GoTo 0" line.

' this DOES NOT work
Public Property Let Phone1(ByVal NewValue As String)
    On Error Resume Next
    If NewValue = "" Then
        Err.Raise 5
    End If
End Property

' this works OK
Public Property Let Phone2(ByVal NewValue As String)
    If NewValue = "" Then
        On Error GoTo 0
        Err.Raise 5
    End If
End Property

Note: Do not accept my comment 'as answer' if it is not for A grade!
0
 
LVL 1

Author Comment

by:redundguy
Comment Utility
Angellll, I have used the number. (1001)
CJ_S, it doesn?t work
Ameba, it doesn?t work.
 
Sorry, I was incorrect. I saw the message
 ?Run time error 1000? when I expected to see:
?I was interrupted by an error?.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 6

Expert Comment

by:simonbennett
Comment Utility
Everyone is right, it should work, unless you are jumping out of scope within your error handler. Only alternative is to raise an event in the server e.g.

Public Event ValidationFailed(byval theError as Error)

...and then trap it in the client

Public Withevents MyObject

Public Sub MyObject_ValidationFailed(byval theError as Error)
   err.raise theError.Number ' and the other error properties!

end sub

HTH and good luck

Simon
0
 
LVL 1

Expert Comment

by:morgan_peat
Comment Utility
In your business-tier DLL, you need to have 'unattended execution' checked in the project properties dialog box.
This will ensure that any errors raised get sent back to the calling DLL.

If you still can't get it to work, post the code in your property Let procedure up and we can have a look at that.
0
 
LVL 22

Expert Comment

by:CJ_S
Comment Utility
Please show how you are raising the error, and the error handling in the function where you raise the error. Then please also show how the error handling is done at the client. That will give us a better view of what you are currently doing.

regards,
CJ
0
 
LVL 1

Author Comment

by:redundguy
Comment Utility
The error is raised in BO tier Property procedure with:
   err.Raise 1000.
The error is handled only in UI tier procedure with the code I have already shown.
Thanks to all!
I'm sory, I have to go out. We'll see tomorow!
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 133 total points
Comment Utility
I think the problem is a VB IDE setting:
Check out the "Break on..." settings in your options,
where you can set to one of these:
* Break on all errors (which is set, i guess)
* Break in Class module
* Break on unhandled errors

Note that the last one behaves as if you compiled the application....

Cheers
0
 
LVL 1

Author Comment

by:redundguy
Comment Utility
Thanks to all
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now