Search code examples
compact-frameworkwindows-cesql-server-2008r2-express

.NET compact framework and SQL Server Express 2008 R2


I am having problems in picking the right collation / locale on a Windows Embedded Compact Edition 6.0 device.

I am using .NET compact framework 2.0 on said device.

I am having difficulties inserting the letters ŠĐČĆŽšđčćž in the database. I am getting a PlatformNotSupported exception.

Available locales on the CE device does not list Croatian or anything similar. When i pick SQL_Latin1_General_CP1_CI_AS as the database/table/column collation it works (in combination with the English (US) locale on the device, but i can't insert previous letters.

The same collation, using Management studio 2008, from a Windows 7 desktop PC, correctly accepts all those letters.

What am I doing wrong?


Solution

  • I was not able to duplicate this on our older SQL 2000 Server, and I would certainly hope that SQL Express 2008 has more for dealing with multilingual issues than SQL 2000.

    I used the following code as my test:

    private const string jp2code = "jp2code.net";
    
    private void Form1_Activated(object sender, EventArgs e) {
      string croatianIn = "ŠĐČĆŽšđčćž";
      string croatianOut = TestCroatian(croatianIn);
      Console.WriteLine(String.Compare(croatianIn, croatianOut));
    }
    
    private string TestCroatian(string input) {
      string result = null;
      string sql = "INSERT INTO SUITEMSG (MsgFrom, [Message]) VALUES (@MsgFrom, @Message);";
      using (SqlCommand cmd = new SqlCommand(sql, Data.Connection)) {
        cmd.Parameters.Add("@MsgFrom", jp2code);
        cmd.Parameters.Add("@Message", input);
        cmd.Connection.Open();
        cmd.ExecuteNonQuery();
      }
      sql = "SELECT [Message] FROM SUITEMSG WHERE MsgFrom=@MsgFrom;";
      using (SqlCommand cmd = new SqlCommand(sql, Data.Connection)) {
        cmd.Parameters.Add("@MsgFrom", jp2code);
        cmd.Connection.Open();
        result = cmd.ExecuteScalar().ToString();
      }
      return result;
    }
    

    Both the input and the output were identical.

    Are you sure there isn't something else you are doing?

    Can you update your question to post a short code example like I have done above to show what does NOT work?