Load DataSet Error: Cannot add a DataRelation or Constraint... - 03-05-2008 , 03:59 PM
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:
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:
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
Re: Load DataSet Error: Cannot add a DataRelation or Constraint... - 02-17-2012 , 11:00 AM
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.
|Thread Tools||Search this Thread|