all groups > dotnet windows forms designtime > may 2005 >
You're in the

dotnet windows forms designtime

group:

Designer adds relations to custom datasets



Designer adds relations to custom datasets Jose Antonio
5/5/2005 2:51:33 AM
dotnet windows forms designtime: Hi,

I have coded a class which inherits from DataSets and
creates two datatables and a datarelation between them.

My intention is to drag it to a form in order to bind the
dataset to several controls.

When I drag the dataset to the form, the designer
automatically adds code in the InitializeComponent method
to create the relation between the tables and adds it to
the dataset.

Obviously, as the DataSet already contains the relation
when the app runs it crashes with the error that the new
relation is already created in the dataset.

Any idea of how can I avoid this behaviour of the winform
designer?

Thanks in advance.

Designer adds relations to custom datasets Jose Antonio
5/5/2005 4:38:47 AM
Checking the code of a typed DataSet I have found that in
the class that inherits form DataSet,
methods "ShouldSerializeTables"
and "ShouldSerializeRelations" must be overriden returning
false.

I have done this change in my code and it works perfectly.

Jose Antonio.
[quoted text, click to view]
AddThis Social Bookmark Button