alaa

alaa

  • NA
  • 166
  • 84.8k

update data using n -tire do nothing

Aug 3 2013 8:17 PM
i have got 3 tire where i carry out my code in my bussiness layer i run code for update

 {
  SortedList Sl = new SortedList();
 
  Sl.Add("@CommandType", TypeOfOperation);
  Sl.Add("@UserName",UserName);
  Sl.Add("@SecondarySchool",SecondarySchool);
  Sl.Add("@University",University);
  Sl.Add("@Qualification",Qualification);
  Sl.Add("@JobTitle",JobTitle);
  Sl.Add("@Company",Company);
  Sl.Add("@PhotoUrl", PhotoUrl);
 
  ProcedureName = "MangeUserInfo";
  if (db.RunProcedure(ProcedureName, Sl) == 1)
  return true;
  else
  return false;

  }


 public bool updateUser(string User, string SecondaryS, string Unvi, string Qua, string jobtitle, string company)
 {
  this.UserName = User;
  this.SecondarySchool = SecondaryS;
  this.University = Unvi;
  this.Qualification = Qua;
  this.JobTitle = jobtitle;
  this.Company = company;
 
  if (Update())
  return true;
  else
  return false;
 }


and in my data access layer

  public void ConnectDB(CommandType CT,string ProNameSQl)
  {
  cn = new SqlConnection("Data Source=.;Initial Catalog=Conversation;Integrated Security=True");
  cmd = new SqlCommand();

  cmd.Connection = cn;
  cmd.CommandType = CT;
  cmd.CommandText = ProNameSQl;
  cn.Open();
  }

 
  public int RunProcedure(string ProcedureName, SortedList Paraval)
  {
  ConnectDB(CommandType.StoredProcedure, ProcedureName);

  for (int x = 0; x < Paraval.Count; x++)
  {
  try
  {

  cmd.Parameters.AddWithValue(Paraval.GetKey(x).ToString(), Paraval.GetByIndex(x));
  }
  catch
  {
  ;
  }
  }
  return ExceNoneQuery();
  }

and then in another layer i use this method to call procedure and run

 public bool Update()
  {
  return LoadProperties2List("u");
  }

at last layer presenation layer

i do that

 protected void btnsave_Click(object sender, EventArgs e)
  {
  //upadate info
  bool Result = false;
  UsersInfo Upd = new UsersInfo();

  try
  {
  Result = Upd.updateUser(username, TxtSecondarySchool.Text, TxtUniversity.Text, TxtQualification.Text, TxtJobTitle.Text, TxtCompany.Text);
  if (Result==true)

  lblMessage.Text = "Record Updated Successfully.";

  else

  lblMessage.Text = "Record couldn't updated";

  }
  catch (Exception ee)

  {

  lblMessage.Text = ee.Message.ToString();

  }  finally

  {

  Upd = null;

  }
}

when i run the code only the result is
lblMessage.Text = "Record couldn't updated";

despite i  do it before and works  where is the error which maks it not to work correctly ??


Answers (3)