Hi,
In my application i need to handle concurrencies:
in DAL i have writtent the following code to retreive a dataset that has a row of data.
The last column of the row is LastUpdatedTime (DateTime)
public DataSet GetARecord(int index) { //code for output
parameter of a stored procedure //stored procedure returnex
EmpIdex(PK), Name, address, LastUpdatedTime(old
Time) . . . .
//code to store the LastUpdatedTime
da.Fill(ds, "Employee"); return ds;
}
|
To store the last updated time, I have added the following line in the GetARecord(int):
public DataSet GetARecord(int index) { //code for output
parameter of a stored procedure . . . .
//I have to store the LastUpdatedTime: "paramDateTime" is
SQLParameter declared globally
paramDateTime = da.UpdateCommand.Parameters.Add("@PUpdatedTimeOLD",
SqlDbType.DateTime, 8,
"UpdatedTime");
paramDateTime.SourceVersion = DataRowVersion.Original;
da.Fill(ds); return ds;
}
|
However, i found the
paramDateTime = da.UpdateCommand.Parameters.Add("@PUpdatedTimeOLD", SqlDbType.DateTime, 8,
"UpdatedTime");
paramDateTime.SourceVersion = DataRowVersion.Original;
|
from an article, according to it this stores the original value of updateTime. But when put a break point and check
for the value that is stored in the, shows null value.
I have added an "void Update(DataSet ds)" to make updates to the table,
public void UpdateEmployee(DataSet ds) { //write code to add parameters, EmpIndex(PK), Name, Address, LastUpdateTime(Old Time) . . .
//calling DataAdapter's update() da.Update(ds."Employee"); }
|
In the above updateEmployee() method, i need to extract value in each column through the Dataset, so i can assign
values to update parameters....
How do i do it?
Here is the article that shows how to do optimistic concurrency based on column values (not dates) . i have made the modification to handle Concurrency based on dates TY