Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Load DataSet Error: Cannot add a DataRelation or Constraint...

121 views
Skip to first unread message

Gregory Butler

unread,
Mar 5, 2008, 4:59:00 PM3/5/08
to
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

unread,
Feb 17, 2012, 12:00:34 PM2/17/12
to

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
0 new messages