Hi everybody,
I have the following structure in my method:
DataSet ds;
1. Code that gets one row of data into ds using ds as OUT parameter
It does it by calling a separate method:
private Boolean GetMax4SaleRow(SqlCommand sqlCommand, out DataSet ds, Int32 max4SaleID, ref String messageText, ref Int32 statusCode)
{
sqlCommand.CommandText = "select * from dbo.max4sale where id = @Id;";
sqlCommand.Parameters.Clear();
sqlCommand.Parameters.Add("@id", SqlDbType.Int).Value = max4SaleID;
return database.ExecuteSqlCommand(sqlCommand, out ds, ref messageText, ref statusCode);
}
2. Code that updates that record using the same sqlCommand object (new CommandText and new parameters)
3. The same code that gets the same row of data into the same ds but it should get the data after update
I re-use the same ds object and the same sqlCommand object in that method.
I observe that my final ds doesn't show the correct data (after the update has been already done).
So, what I may be missing here?
If needed, I can post the code of the method or the relevant points in that method.
UPDATE. Never mind - it turned out we automatically added begin transaction rollback transaction statements, so the changes were not saved.
If it's not broken, fix it until it is.
My Blog