Problems reading from Oracle

I just installed the Oracle express database and am trying to read some data from the table that I posted there:

using (OracleConnection conn = new OracleConnection("Data Source=localhost:1521/xe;Persist Security Info=True;User ID=SYSTEM;Password=SYSTEMPASSWORD"))
{
    OracleCommand command = new OracleCommand("SELECT * FROM Persons WHERE Firstname = 'John'", conn);
    conn.Open();
    OracleDataReader reader = command.ExecuteReader();

    try
    {
        while (reader.Read())
        {
            string strResult = reader.GetString(0);
        }
    }
    catch (OracleException oex)
    {
        MessageBox.Show(oex.Message, "Oracle error");
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "Error");
    }
    finally
    {
        reader.Close();
    }
} 

On while (reader.Read())it just shuts down, since the reader does not contain any data. What's wrong? Connectionstring? I ran the same SELECTin a commandprompt tool that is installed using Oracle express and it works great.

+5
source share
4 answers

, , - /, , . . . , , .

+5

SYSTEM? , "select object_name from user_objects" , .

+2

, Oracle .Net, , ( "xe"?). SQL Server INITIAL CATALOGUE . , : http://www.connectionstrings.com/oracle. .

+1

, ...

I had the same problem with access to the view, and it turned out that the corresponding privileges were not granted to it. Once I granted the SELECT privilege to my user ID, I could get my data.

0
source

All Articles