DataRelations and ConstraintExceptions...

concise

Member
Joined
Jan 28, 2003
Messages
5
Hello -

Im writing a tiered application for the first time in vb.net, and Im coming across a few sticking points.

In my database, I have setup relationships to preserve the integrity of the data.

I need to mimic these same relationships in the DataSet, so that I can guide the users actions and prevent them from violating the constraints in the database.

So, Ive implemeted some parent child DataRelations using the visual tool in the XML Designer, as per this article...

http://msdn.microsoft.com/library/d...skcreatingdatasetrelationswithxmldesigner.asp

Now I want exceptions to be thrown when I violate these constraints set in my dataset. I cant seem to be able to catch any violations. What exception should I be trying to catch? Ive used generic "Exception" and "ConstraintException" neither of them throw. Yet I know the integrity is working, because if I select a rule to be enforced when I violate a contraint - I see it take place [delete, update, whatever...]

So, the violations of the dataset arent getting caught, and the database is throwing exceptions - which is obviously no good to the end user.

I need to catch exceptions because I have to ask the user what he wants to do before I cascade some deletes, or whatever is going to happen based on this user input.

Any help much appreciated...

TIA.
 
I have no problem catching the exceptions. What code are you using to update your dataset?

Heres a sample of something that breaks for me:
Code:
try
{
	ds.Tables["Folder"].Rows[0]["FolderTypeID"] = 99;
}
catch(InvalidConstraintException e)
{
	Debug.WriteLine(e.Message);
}

In my table "Folder" the "FolderTypeID" of 99 isnt valid. I have a relationship to a parent table that only has FolderTypeID values from 1 to 10.

-Nerseus
 
Back
Top