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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SqlClient.DataReader locks records? (ADO.Net)

Status
Not open for further replies.

JFritzler

Programmer
Jul 19, 2001
18
US
Does anyone know if SqlClient.DataReader locks the rows that is it currently reading?

I have a recursive call that that tries to execute "update" commands on the current row but it times out. (These are simle commands like "update table set field = value where primatykeyfield = 2". Nothing fancy, - in fact they run fine in the query analyser, but not at runtime.)

My theory is that the ADO.Net Reader locks the "read" rows. Does this sound possible? If so, can the behavior be changed?
 
This question is better suited for a vb.net forum or asp.net forum. They would know more about .net questions than this sql server forum.

to answer your question, check to see if you closed the reader, and/or connection before attempting to execute the udpate command. the reader is used to access the records and get them to the end user to minipulate. The reader shouldn't be opened any longer than it needs to be. to allow other users and command access to the information.

Jason Meckley
Database Analyst
WITF
 
Ok, I will post it there.
But I can't close the reader because I have more rows to process (to "read"). I need to use the "update" sql to mark the current row as being processed so it won't be processed the next time this feature is executed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top