Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not getting anything in my reader object

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
I'm running a query which is fine using OracleCommand.

Then create a OracleDataReader object.

Then I do a reader.Read();

The I try and print out the results to a textbox:

OracleResultsTextBox.Text = reader "EMA_AUTHENTICATION"].ToString();

And I get an exception:-

[InvalidOperationException: Invalid attempt to read when no data is present.]
System.Data.OracleClient.OracleDataReader.AssertReaderHasData() +43
System.Data.OracleClient.OracleDataReader.GetValue(Int32 i) +21
System.Data.OracleClient.OracleDataReader.get_Item(String name) +20
RADashboard.RADashboard.RetrieveColours() in c:\inetpub\ RADashboard.RADashboard.CheckSetConnectionOracle() in c:\inetpub\ RADashboard.RADashboard.Page_Load(Object sender, EventArgs e) in c:\inetpub\ System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724


-------------------------------------------------

When I run OracleResultsTextBox.Text = reader.HasRows.ToString();

I get the result "false". I don't understand this because I know there is an entry in the table.

Can anyone help please?
 
Probably a dumb question, but have you verified your SQL works correctly? Try something simple like a SELECT * FROM <table> to see what you get.

Chip H.
 
Yep I've verified that.

I copied it and pasted directly from the code into the window.

 
I haven't used the Oracle provider, but do you need to do a .MoveFirst() before doing a .Read()?

Chip H.
 
Not to my knowledge. There doesn't appear to be a MoveFirst method for this object.

Thanks,

Any other ideas?
 
Nope. Other than to step through the code and watch the assignments being made.

Chip H.
 
Well it seems I made a huge mistake this time.

I populated my table but didn't commit the changes :)

Sorry. Thanks for your help.
 
Ahh, that's right. Oracle doesn't auto-commit.
Glad you found your problem.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top