How to enforce constraint in VB.Net 2005 using Oracle Database ?

L

Luqman

I have created a form using single Table which has customerId and
companyName field, using Typed Dataset.

Now, if I click on Delete Button of Binding Navigator, the Customer Record
is deleted from Dataset, however when I click on Save Button of Binding
Navigator, Oracle raises Constraint violation Error, child record found."

Why can't VB.Net check the child record / constraint violation when I
clicked on Delete Button, any idea please ?

I have also checked the TableAdapter Property in Dataset, and Enforce
Constraint is True there.

I have put only one table in Dataset i.e. Customers, which is linked with
Invoice Table in Oracle, do I have to put Invoice Table also in Dataset ?

Further, how can I cancel / EndEdit on Delete Button of Binding Navigator ?

I tried putting some condition in Delete Button and raised some msgbox and
exit sub, but still it deleted the record.


Best Regards,

Luqman
 
P

Patrice

"EnforceConstraint" applies to constraints defined inside the DataSet. It
doesn't mean that the DataSet will automatically check constraints defined
in the source database (remember that datasets are disconnected anyway)...

Try the documentation at
http://msdn2.microsoft.com/en-us/library/st1t2c35.aspx (Adding Constraints
to a (Data)Table). If you don't need them all you could get a single record
and a single field each time the main record has one child or more, just to
be able to establish the constraint inside the dataset).

Another option could be to have a flag (basically the same as above but in a
single table) in the select query so that you can disable the delete button
when you are not allowed to delete this record ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top