The error message "The specified locale is not supported on this operating system."

I create a database file using the following method.

public bool CreateDatabaseFile() { try { Stream file = File.Create(DBPath); file.Close(); return true; } catch (Exception) { return false; } } 

But when I call

  public void CreateDatabaseStruct() { var queries = new List<string> { "create table contacts (\"name\" nvarchar,\"emails\" nvarchar);", "create table errors (\"code\" int, message nvarchar);" }; foreach (string query in queries) { var con = new SqlCeConnection(connectionString); con.Open(); var cmd = con.CreateCommand(); cmd.CommandText = query; cmd.ExecuteNonQuery(); con.Close(); } } 

he returns

The specified locale is not supported on this operating system [LCD - 1].

How to fix it?

UPDATE

Connection string:

  public static readonly string DBPath = "db.sdf"; public static readonly string connectionString = String.Format("Data Source={0}; Password=...", DBPath); 
+4
source share
2 answers

The solution creates it using SqlCeEngine.CreateDatabase () .

+3
source

Do you specify the locale identifier in connection via LCD=#### (where #### is the supported 4-digit LCID)? If so, are you sure that it is supported on your operating system?

If not, it is possible that your operating system has a different culture that is not supported by the database.

Please post your connection string and give more information about which O / S you are using (as @MusiGenesis mentioned).

+2
source

Source: https://habr.com/ru/post/1390239/


All Articles