JG Vimalan's Blog

It is all about coding!

{System.InvalidOperationException: No data exists for the row or column.

I got this error when I was trying to read values from an OracleDataReader in my C# application.

Here is the code snippet which caused the issue,

OracleDataReader orReader = command.ExecuteReader();
if (orReader.HasRows)
string email = orReader.GetValue(0).ToString();

The cause of the error is simple, I have not used orReader.Read() method.

All I have done is, just verified whether reader has rows. The correct code is as follows,

OracleDataReader orReader = command.ExecuteReader();
while (orReader.Read())
string email = orReader.GetValue(0).ToString();


June 25, 2011 - Posted by | C#.NET, Oracle

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: