Strings Unicode em um banco de dados SQLite
Eu gostaria de alguma ajuda com o meu código Visual Studio C # com a inserção de strings unicode em um banco de dados SQLite.
Abaixo está meu código de teste para escrever uma string de teste no banco de dados:
string testStr = "á Á ñ ç é á";
SQLiteConnection mydataConnection = new SQLiteConnection(); // setup new sql connection obj
try
{
//// SQLite DB
mydataConnection.ConnectionString =
"Data Source=C:\\Users\\John\\Desktop\\location.db; Version=3; UseUTF16Encoding=True;Synchronous=Normal;New=False"; // set up the connection string
mydataConnection.Open(); // open the connection to the db
SQLiteCommand myCmd = new SQLiteCommand(); // create a new command object
myCmd.Connection = mydataConnection; // whats its connected to, see above connection string
SQLiteParameterCollection myParameters = myCmd.Parameters; // good pratice to use parameters to pass data to db
myParameters.AddWithValue("@name", testStr); //
myCmd.CommandText = "INSERT INTO location (name) VALUES (@name)";
myCmd.ExecuteNonQuery();
}
catch (SQLiteException d)
{
string myerror = "Database Error" + d;
MessageBox.Show(myerror);
}
finally // good pratice to close db connection in a finally so exceptions dont leave open.
{
mydataConnection.Close();
}
Quando vejo o banco de dados / tabela (usando o SQLite Administrator) a string se parece com isso: á à à à à à água
Como um teste, posso copiar e colar a string diretamente no banco de dados usando o SQLite Administrator e a string é salva e pode ser vista posteriormente como OK.
Eu tentei alternar "UseUTF16Encoding = True;" Verdadeiro / Falso - sem diferença.
Alguma idéia do que estou fazendo de errado.