I am trying with oracle database to Insert and select Hebrew letters and it not working well.
I tried
Insert into mytable values ('היי');
and the result is ??? and not היי
can someone help me with that
编辑:
现在,在我向 DBA 询问希伯来语选项后,我可以从 sqlplus 中用希伯来语编写
但现在从我的项目中它仍然写 ???
我的代码是
OleDbConnection conn = Connect();
conn.Open();
OleDbCommand com = new OleDbCommand("Insert into mytable values ('היי')", conn);
com.ExecuteNonQuery();
结果还是???
最佳答案
我无法真正测试这个,因为我对你的数据库一无所知(甚至不知道你的列名),但你应该使用参数执行该命令:
var testString = "היי"; // Do be aware that Visual Studio displays Hebrew text right-to-left, so the actual string is reversed from what you see.
using (OleDbConnection conn = Connect())
{
conn.Open();
using (OleDbCommand com = conn.CreateCommand())
{
// OleDbCommand com = new OleDbCommand("Insert into mytable values ('היי')", conn);
com.CommandText = "Insert into mytable values (?)";
com.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.VarWChar }).Value = testString;
com.ExecuteNonQuery();
}
}
此外,不要忘记通过 using
语句处理您的一次性用品。
相关,here是一份报告,使用参数化查询修复了 OracleCommand
的类似问题。
关于c# - 来自 Connection 的希伯来语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27577841/