ORA-00911: invalid character Error in C# Application

1.6k views Asked by At

I'm created app to connect Oracle Database XE 11g with ODAC 12, and take an error called "invalid character". This is my 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;"

and code here

    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();
        }
    }

Somebody help me!

1

There are 1 answers

2
Justin Cave On

Standalone queries executed from your C# application shouldn't include the semicolon ; at the end. If you remove that, the ORA-00911 error should go away.