i have a problem while reading data with DataReader cannot update same record with same connection. Its getting timeout.
Here is my code listed below:
mycon = new DBManager(DataProvider.SqlServer,ConnectionStr);
mycon.Open();
while (mycon.DataReader.Read())
{
Id = mycon.DataReader["ID"].ToString();
sql.Length = 0;
sql.Append("Update [Table1] Set [Name] = XXX Where [ID] = " + Id + "");
mycon.ExecuteNonQuery(CommandType.Text, sql.ToString());
}
and my connection settings are
Connect Timeout=30;MultipleActiveResultSets=true;pooling=yes
already fixed that problem using DataTable and looping on it. not cause any problem but i want to use datareader. Anyone can help me about that.
UPDATEcommand to do the whole thing in bulk. Also, you should not be cachingDataReader, you need to dispose it as soon as you're done. I don't care whatDBManagerdoes, it's wrong to hold these objects in a cacheMultipleActiveResultSets=truegives me a oportunity the do multiple commands execute. Anyway as Steve's link says query is locking till end up datareader.