473,324 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Constraint Exception Handling with C1 DataObjects

Hi All,

I've posted this question on the ComponentOne news group, but I thought it
couldn't hurt to post it here as well, since, I’m assuming, some others out
there are using the C1 controls for VB.NET.
This is what I have:

VB.Net form with a c1FlexGrid and some c1Textboxes
C1ExpressConnection to an Access DB
C1ExpressTable
C1dbNavigator
The C1FlexGrid and C1textboxes are bound to the C1expresstable
Column3 (in the C1expresstable is a unique index, calculated with the
expression [column1]+'-'+[column2].

So far, this all works. When a new row is added, the user enters data in the
textbox bound to column1, then column2 and the calculation expression fills
column3. However, if the calculation produces a non-unique value for
column3, an error (Constraint Exception) is produced. The error is not
actually the problem (since I expect the error). My problem is figuring out
how to catch the error, so that I can show my own error message, clear the
current values in Col1, Col2, and Col3, and set the focus back to the
textbox bound
to column1. Does that make sense?

I've looked through the docs and tutorials and found enough to know that I
can catch the error and do what I want to do. Unfortunately, I didn't find
enough information (or an example) to actually implement the solution.

All help and comments will be greatly appreciated!!

Thanks
Lee
Nov 21 '05 #1
6 2297
Hi

When the error, did it popup an error dialog?
If so, I think the ComponentOne has handle the error inside the control.
Since we have no the source code how about they implement the control, so
I think the component one support website would be the correct place.

Thanks for you understanding.

If you still have any concern please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2
Thanks Peter,

Yes, there is an error dialog that basically says the value the user is
trying to add to the column is not unique (since the column is the Primary
Key). I expect this error to occur. But, I want to catch the error and use
my own error dialog (which will be a bit less cryptic and give the user a
choice to cancel the new row, or re-enter a unique value). Unfortunately,
the C1 website has little to offer, other than a copy of the help files,
which are not very clear.

The reason I decided to post here to begin with was that I was hoping that
since C1 and Microsoft had a deal with the VB Resource Kit and C1 Studio.Net
that there would be enough other people on this list using the C1
components.

the C1 documentation makes it clear that this type of exception can be
handled, but it doesn't say which ErrorEventHandler to use, and I've tried
just about every combination to see which handler catches this constraint
exception (with no luck!)

I've posted the same info on the C1.Data Newsgroup, so we'll see who wins
the prize by providing me with the answer first!

Regards,
Lee

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:SC*************@TK2MSFTNGXA02.phx.gbl...
Hi

When the error, did it popup an error dialog?
If so, I think the ComponentOne has handle the error inside the control.
Since we have no the source code how about they implement the control, so
I think the component one support website would be the correct place.

Thanks for you understanding.

If you still have any concern please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #3
Hi

I am not familar with the c1FlexGrid.
Basically as a common control in vs.net, e.g. TextBox, it has validate
event which will be raised after the focus is lost. And then we can handle
our validate method in the event handler, e.g. throw an exception or just
pop up a msgbox. I think the c1FlexGrid may use the similar approach, while
since it pop up a msgbox which is not an exception. If we do not handle an
exception, the exception will be thrown up through the call stack until the
program crash if we did not handle it in any place in the program. While a
msgbox if just a message, it is similar with the code below.
validate_handle
{
if(notvalid)
msgbox "something is wrong";
}

So in this way we have no idea about that the validate_handle failed.
So the problem depends on how the validate_handle is implemented, e.g.
will it raise another errorevent or something else to give the user a
chance to handle?

Hope this helps.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4
Hello Peter,

I've got the error handling stuff worked out. I finally got email from C1
and they told me which error handler would capture this particular event.
the particular handler that they use, by name, didn't seem to be the right
choice, so I never even tried it.

Anyway, I'm intercepting the exception, displaying my own message, and going
on from there. But I discovered another small issue. Maybe you can shed some
light on it for me.

As I mentioned before, I have textboxes that are bound to various columns in
a table. TB1 goes to Column1, TB2 to Column2, etc. And the Primary key is
Column3. There is a calculation in the table that combines the vales of
Column1 and Column2. If the user enters a value in TB1, then TB2 and the
calculation produces a non-unique value for Column3, the exception is
thrown. The user has a choice from the message box to re-enter the values in
TB1 and TB2, or just cancel the new entry.

Here's the problem. Let's say the user decides to cancel. What I do is call
a Fill on the Connection, which updates the table. This wipes out the new
row the user was tring to add and displays the values from the last row of
data in the textboxes on the form. Or, at least, this is what is supposed to
happen! For some reason, the value in TB2 (the textbox that had focus just
before the exception occured) retains the value the user entered. The table
however does not have this value, only the textbox. All of the other
textboxes are updated correctly with the contents of the current row of the
table. As a quick test, I added a new row, entered a value in TB2 first,
then in TB1 (the values intentionally caused a Primary Key exception). In
this case, the value in TB2 is correct, but the value in TB1 remains
unchanged.

In my error event code, I have even added TB2.Text="" (or any text), but the
value that was typed into the textbox remains, even after the table has been
re-filled. If I use the record navigator to move to the previous record,
then back, the textbox is fine.

This same behavior occurs whether I use a VB.NET textbox or a C1Textbox. Do
you have any idea what might cause this behavior?

Regards,
Lee
""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:J5**************@TK2MSFTNGXA02.phx.gbl...
Hi

I am not familar with the c1FlexGrid.
Basically as a common control in vs.net, e.g. TextBox, it has validate
event which will be raised after the focus is lost. And then we can handle
our validate method in the event handler, e.g. throw an exception or just
pop up a msgbox. I think the c1FlexGrid may use the similar approach,
while
since it pop up a msgbox which is not an exception. If we do not handle an
exception, the exception will be thrown up through the call stack until
the
program crash if we did not handle it in any place in the program. While a
msgbox if just a message, it is similar with the code below.
validate_handle
{
if(notvalid)
msgbox "something is wrong";
}

So in this way we have no idea about that the validate_handle failed.
So the problem depends on how the validate_handle is implemented, e.g.
will it raise another errorevent or something else to give the user a
chance to handle?

Hope this helps.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #5
C1 has their own newsgroup server also.

news://News.ComponentOne.com

"lgbjr" <lg***@online.nospam> wrote in message
news:ex****************@TK2MSFTNGP09.phx.gbl...
Thanks Peter,

Yes, there is an error dialog that basically says the value the user is
trying to add to the column is not unique (since the column is the Primary
Key). I expect this error to occur. But, I want to catch the error and use
my own error dialog (which will be a bit less cryptic and give the user a
choice to cancel the new row, or re-enter a unique value). Unfortunately,
the C1 website has little to offer, other than a copy of the help files,
which are not very clear.

The reason I decided to post here to begin with was that I was hoping that
since C1 and Microsoft had a deal with the VB Resource Kit and C1
Studio.Net that there would be enough other people on this list using the
C1 components.

the C1 documentation makes it clear that this type of exception can be
handled, but it doesn't say which ErrorEventHandler to use, and I've tried
just about every combination to see which handler catches this constraint
exception (with no luck!)

I've posted the same info on the C1.Data Newsgroup, so we'll see who wins
the prize by providing me with the answer first!

Regards,
Lee

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:SC*************@TK2MSFTNGXA02.phx.gbl...
Hi

When the error, did it popup an error dialog?
If so, I think the ComponentOne has handle the error inside the control.
Since we have no the source code how about they implement the control, so
I think the component one support website would be the correct place.

Thanks for you understanding.

If you still have any concern please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.


Nov 21 '05 #6
Hi

I think you may try to write the databinding and fill code in a function,
and then call it from the form_load and other place you want to refresh the
databing to the database to see if the problem persists.
You may have a try and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses...
7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
7
by: Brian Keating | last post by:
Hi there, Is it possible to add a unique constraint on two columns in a table, so that the constraint is a composite of the two? i.e. these two columns together should be unique...? i.e....
5
by: clickon | last post by:
I am creating a "setup" page that allows users to fill out various tables of key,value pairs that are basically the table for foreign keys within a master table. It all works very well, but when a...
3
by: ferg | last post by:
I have a Customer table. The table has two different CHECK constraints. Then there is the Customer details dialog, which provides the user with an UI for changing users. I have some UPDATE sql,...
1
by: =?Utf-8?B?VGFz?= | last post by:
Hi, first of all, I'm using: Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP.050727-7600) Microsoft .NET Framework Version 2.0.50727 Installed Edition: C# Express. I have added a...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.