我创建了将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();
}
}
有人帮助我!
答案 0 :(得分:1)
从C#应用程序执行的独立查询最后不应包含分号;
。如果删除它,ORA-00911错误应该消失。