c# - 来自 Connection 的希伯来语

标签 c# oledb sqlplus oledbconnection oledbcommand

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/

相关文章:

oracle - 如何使用 sqlplus 作为 sysdba 连接到不同的 oracle 实例?

sql - 无法像@{file.sql} oracle sqlplus 语法那样从 SQL Server 查询管理器执行 SQL 脚本?

c# - 无法对在OS X上运行的.net Core 3.1 Worker服务进行泊坞化

c# - 将对象添加到空列表

c# - 在业务对象和集合中使用泛型

c# - 使用此 INSERT INTO 语句和 .NET OleDb 命名空间时如何解决语法错误?

c# - OleDb 异常

c# - Windows 搜索查询文件内容中单词/子字符串的*部分*

c# - 如何将ldap请求更改为关系数据库?

oracle - 当 PL/SQL 编译失败时如何让 SQL*Plus 退出