petre ricardo

petre ricardo

  • NA
  • 194
  • 0

How do i rewrite this code to handle Optimistic concurrency!

Oct 30 2009 1:37 PM

hi,
I know usung the wizards this is damn easy but i need to do this from code:
I have written this code in my DAL to retrreive A record by user name... i need to re-write the code to handle optimistic concurrecny.... could any one give me few pointer or modification to my code:
 
 
public DataSet GetRecord(string userName)
{
da.SelectCommand = cmdSelect;
da.SelectCommand.Parameters.Clear();
ds.Tables.Clear();
da.SelectCommand.CommandType =
CommandType.StoredProcedure;
da.SelectCommand.CommandText =
"ProcGetUsers";
da.SelectCommand.Connection = con;
da.SelectCommand.Parameters.Add(
"@PUserName", SqlDbType.NVarChar, 50, "UserName");
da.SelectCommand.Parameters[
"@PUserName"].Value = userName;
da.SelectCommand.Parameters.Add(
"@PFirstName", SqlDbType.NVarChar, 50, "FirstName");
da.SelectCommand.Parameters[
"@PFirstName"].Direction = ParameterDirection.Output;
da.SelectCommand.Parameters.Add(
"@PLastName", SqlDbType.NVarChar, 50, "LastName");
da.SelectCommand.Parameters[
"@PLastName"].Direction = ParameterDirection.Output;
da.SelectCommand.Parameters.Add(
"@PUpdatedTime", SqlDbType.DateTime, -1, "UpdatedTime");
da.SelectCommand.Parameters[
"@PUpdatedTime"].Direction = ParameterDirection.Output;
da.SelectCommand.Connection.Open();
da.Fill(ds);
da.SelectCommand.Connection.Close();
return ds;
}

 

Answers (6)