== Why is this an issue?

When you create a ``++DataTable++`` or ``++DataSet++``, you should set the locale explicitly. By default, the locale for these types is the current culture. For data that is stored in a database or file and is shared globally, the locale should ordinarily be set to the invariant culture (``++CultureInfo.InvariantCulture++``).


This rule raises an issue when ``++System.Data.DataTable++`` or ``++System.Data.DataSet++`` instances are created without explicitly setting the locale property (``++DataTable.Locale++`` or ``++DataSet.Locale++``).


=== Noncompliant code example

[source,csharp]
----
using System;
using System.Data;

namespace MyLibrary
{
    public class Foo
    {
        public DataTable CreateTable()
        {
            DataTable table = new DataTable("Customers"); // Noncompliant table.Locale not set
            DataColumn key = table.Columns.Add("ID", typeof(Int32));

            key.AllowDBNull = false;
            key.Unique = true;
            table.Columns.Add("LastName", typeof(String));
            table.Columns.Add("FirstName", typeof(String));
            return table;
        }
    }
}
----


=== Compliant solution

[source,csharp]
----
using System;
using System.Data;
using System.Globalization;

namespace MyLibrary
{
    public class Foo
    {
        public DataTable CreateTable()
        {
            DataTable table = new DataTable("Customers");
            table.Locale = CultureInfo.InvariantCulture;
            DataColumn key = table.Columns.Add("ID", typeof(Int32));

            key.AllowDBNull = false;
            key.Unique = true;
            table.Columns.Add("LastName", typeof(String));
            table.Columns.Add("FirstName", typeof(String));
            return table;
        }
    }
}
----

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Set the locale for this ["DataTable" | "DataSet"].


=== Highlighting

"DataTable" or "DataSet" creation


endif::env-github,rspecator-view[]
