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

IsolationLevel.RepeatableRead not doing what I thought it would..

Status
Not open for further replies.

tyreejp

Programmer
Apr 20, 2005
114
US
I'm trying to fill a dataset with records in a transaction and have those records locked so no one else can access them until I've made my updates and saved them back to the DB. I execute the code below and my dataset gets the records I want. While the transaction is still open, I alt+tab to Query Analyzer and try to perform an update on one of the records that is already in my dataset and the update works. I then alt+tab back to my little test app and commit the transaction. Exceptions are never thrown but I'm not getting the effect I want, which is to not allow anyone else access to those records while the application is editing. Any suggestions?? Thanks!

try {
ST = CN.BeginTransaction(IsolationLevel.RepeatableRead,"test");
CM = new SqlCommand(txtSQL.Text,CN,ST);
CM.CommandType = CommandType.Text;
DA = new SqlDataAdapter();
DS = new DataSet();
DA.SelectCommand = CM;
DA.SelectCommand.Transaction = ST;
DA.Fill(DS, "MyTable");

}
catch(Exception ex){
MessageBox.Show(ex.Message);
return;
}

--
James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top