简体   繁体   中英

ORA-00911: invalid character Error in C# Application

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM