Discussion:
Load DataSet Error: Cannot add a DataRelation or Constraint...
(too old to reply)
Gregory Butler
2008-03-05 21:59:00 UTC
Permalink
I've got a typed data set with several child tables compiled under 'en-US' as
the locale. When the app is run under a different locale (through, e.g.,
changing regional settings, an MUI, etc.), the following exception occurs:

"Failed to load dataset because of the following error:
Cannot add a DataRelation or Constraint that has different Locale or
CaseSensitive settings between its parent and child tables."

This was apparently reported as a VS bug several years ago:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=106466

I tried the "change the UseCurrentLocale attribute to false" suggestion, but
to no avail. Ultimately, I had to add the following code to to the
Designer.cs file in the InitClass() method after the last table is added but
before the first relation is created:


this.Locale =
System.Threading.Thread.CurrentThread.CurrentCulture;

foreach (System.Data.DataTable dt in base.Tables)
{
dt.Locale = this.Locale;
}

This is the only solution that I've found effective, but obviously consider
it inadequate since I had to alter generated code. Note that I am using this
version 8.0.50727.762 of VS and 2.0 SP1 of .NET.

Any feedback would be appreciated. Thanks
Michael Collins
2012-02-17 17:00:34 UTC
Permalink
I also tried the "change the UseCurrentLocale attribute to false" suggestion, but to no avail.

Then I discovered on another Microsoft site (see below) that if you change the UseCurrentLocale attribute to false, you must also make sure that the dataset element also has the attribute msdata:Locale="en-us", which in my case, didn't exist, and I had to add it.

That fixed the error for me.

http://msdn.microsoft.com/en-us/library/ff420727.aspx
Post by Gregory Butler
I've got a typed data set with several child tables compiled under 'en-US' as
the locale. When the app is run under a different locale (through, e.g.,
Cannot add a DataRelation or Constraint that has different Locale or
CaseSensitive settings between its parent and child tables."
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=106466
I tried the "change the UseCurrentLocale attribute to false" suggestion, but
to no avail. Ultimately, I had to add the following code to to the
Designer.cs file in the InitClass() method after the last table is added but
this.Locale =
System.Threading.Thread.CurrentThread.CurrentCulture;
foreach (System.Data.DataTable dt in base.Tables)
{
dt.Locale = this.Locale;
}
This is the only solution that I've found effective, but obviously consider
it inadequate since I had to alter generated code. Note that I am using this
version 8.0.50727.762 of VS and 2.0 SP1 of .NET.
Any feedback would be appreciated. Thanks
Loading...