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
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