I've just installed an Oracle express database and am trying to read some data from a table I've put in 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 the while (reader.Read())
it just quits since the reader does not hold any data. What is wrong? Connectionstring
? I've run the same SELECT
in the commandprompt tool that is installed with Oracle express and it works fine.
Comments. Nope, no dirty reads in Oracle. No blocking in Oracle either.
Partitioning your data and creating local partitioned indexes can improve your query performance. On a partitioned table, each partition has its own set of index tables. Effectively, there are multiple indexes, but the results from each are combined as necessary to produce the final result set.
Dirty Reads A dirty read is when you see uncommitted rows in another transaction. There is no guarantee the other transaction will commit. So when these are possible, you could return data that was never saved to the database! Dirty reads are impossible in Oracle Database.
First thing to do when connection to any system is see/test if it succeeded and after that continue. Without these simple kinds of tests your application is bound to behave like a time-bomb. A bit of defensive programming will make your projects a lot easier to debug. Not really the answer you are looking for but currently the state of the connection is not clear at query execution time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With