Are the constraints in a dataset exposed in strongly-typed fashion?

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,081
Programming Experience
10+
I have a dataset with one table that may have several types of addresses in. Though I have set EnforceConstraints = false on the dataset in the dataset designer, and I have set EnforceCOnstraints = false on the instance of it dropped onto the form designer, I still encounter ConstraintExceptions (but only once) when working with the dataset.

I now wish to attempt a logical step of switching off the constraints I will not use in the context.

For example, when dealing with a Bank's address, the constraint
BANKS_ADDRESSESDataRelation will be used
But the CUSTOMERS_ADDRESSESDataRelation and the SUPPLIERS_ADDRESSESDataRelations will not be used.


I am wondering if these can be accessed via a property, such as:

Me.MyDataSetInstance.CUSTOMERS_ADDRESSESDataRelationInstance.Enabled = false


So far I have only found the un-typed way of:

Me.MyDataSetInstance.Constraints("CUSTOMERS_ADDRESSESDataRelation")...


Any ideas? Thanks much in advance!
Matt
 
Rather than being right off of the DatasetInstance, is it maybe off of the Contraints object? That's were I think I woujld expect to find it.... but then I could be wrong.

-tg
 
So far I have only found the un-typed way of:

Me.MyDataSetInstance.Constraints("CUSTOMERS_ADDRESSESDataRelation")...

When you said "off the constraints object" did you mean the .Constraints collection of the dataset? Its the only thing Ive found so far that seems to expose them, so where we have these equivalence:

MyDataSetInstance.Tables.Item("TableA")
MyDataSetInstance.Tables("TableA") 'shorthand for above
MyDataSetInstance.TableA 'strongly typed


I havent so far seen an equivalence of the constraints:

MyDataSetInstance.Constraints("ConstraintA")

If you meant a different Constraints object.. where could I find that info?
 
No, you interpreted my comments correctly.... MyDataSetInstance.Constraints.MyConstraintsHere.... hmmm.... unfortunately I haven't had the opportunity to work with this stuff too much (I've got everything wrapped up into business objects).

Sorry.

-tg
 
I shall have a look for them.. didnt initially see them in Intellisense, but I might not have been looking very hard! I'll let you know! :D
 
I'd say no to them being exposed strongly typed on the Constraints collection.. for that, i think it would have to be specialized. I'll proceed un-typed (memory test on the names)! :)
 

Attachments

  • Image1.png
    Image1.png
    13 KB · Views: 33
Back
Top