ORA-00911:C#应用程序中出现无效字符错误

本文关键字:无效 字符 错误 应用程序 ORA-00911 | 更新日期: 2023-09-27 18:30:13

我创建了一个应用程序,用于连接Oracle Database XE 11g和ODAC 12,并接受一个名为"无效字符"的错误。这是我的ConnectionString:

connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)));User Id=hr;Password=12345;"

并在此处编码

    private void BtnConnect_OnClick(object sender, RoutedEventArgs e)
    {
        var sql = @"SELECT FIRST_NAME FROM EMPLOYEES
                    WHERE EMPLOYEE_ID = 120;";
        var command = new OracleCommand(sql, Connection.Connect);
        try
        {
            command.Connection.Open();
            var reader = command.ExecuteScalar();
            if (reader != null)
            {
                LblMessage.Content = "Connect Succeeded ";
                LblMessage.Foreground = Brushes.Green;
            }
            else
            {
                LblMessage.Content = "Connect Failed";
                LblMessage.Foreground = Brushes.Red;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            command.Connection.Close();
        }
    }

谁来帮帮我!

ORA-00911:C#应用程序中出现无效字符错误

从C#应用程序执行的独立查询不应在末尾包含分号;。如果您删除了它,ORA-00911错误应该会消失。