Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello -

 

I'm writing a tiered application for the first time in vb.net, and I'm 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, I've implemeted some parent child DataRelations using the visual tool in the XML Designer, as per this article...

 

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingdatasetrelationswithxmldesigner.asp

 

Now I want exceptions to be thrown when I violate these constraints set in my dataset. I can't seem to be able to catch any violations. What exception should I be trying to catch? I've 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 aren't 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.

  • *Experts*
Posted

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

 

Here's a sample of something that breaks for me:

try
{
ds.Tables["Folder"].Rows[0]["FolderTypeID"] = 99;
}
catch(InvalidConstraintException e)
{
Debug.WriteLine(e.Message);
}

 

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

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...