Re: DataReader Behavior
Posted by: Simon Rigby
Date: February 03, 2005 11:57AM

Hi Oscar,

1. By all means, while looping you can get values from the current record to insert or update, but only by adding a seperate command object in the loop and inserting or updating through it. Data Reader is readonly / forward only.

2. Yes. But they must be on seperate connections. The DataReader has full control of a connection and the connection can not be user for anything else until the attached reader is closed.

3. I've not noticed anything wrong with the MySqlDataReader. It performs as I would expect if the table is empty or contains rows. I use them frequently with SQL Server/MSDE (SqlDataReader) with no problems.

4. I must admit I have not used this property before. My usual course of action for testing for an empty reader is as follows.

Try
while dr.read
'Do Something
end while
Catch ex as InvalidOperationException
'Do the stuff you need to do for an empty reader
Finally
dr.Close()
End Try

No suggesting that this is the best way to do it (I must admit I'd never noticed the HasRows Property) but might be worth a try to see if it gives you the same problems.

Maybe drop a full code example of what your trying to do (including anything happening within the loop).

Hope this helps.

Simon Rigby

Options: ReplyQuote


Subject
Written By
Posted
February 03, 2005 09:46AM
Re: DataReader Behavior
February 03, 2005 11:57AM
February 03, 2005 12:54PM
February 03, 2005 05:13PM
February 04, 2005 08:11AM
February 04, 2005 08:56AM
February 04, 2005 08:49PM
February 05, 2005 09:25AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.