Priyank Khare

Priyank Khare

  • NA
  • 256
  • 75.7k

sql upate command

Jul 20 2012 8:49 AM
hello sir,

my problem is as folows:-

Amenities.aspx-

protected void roombtnselect_Click(object sender, EventArgs e)
  {
  string Id = null;
  string hname = null;
  string rtype = null;
  foreach (GridViewRow row in GridView2.Rows)
  {
  CheckBox chkbx = (CheckBox)row.FindControl("CheckBox3");
  if (chkbx.Checked)
  {
  hname = row.Cells[1].Text.ToString();
  rtype = row.Cells[6].Text.ToString();

  Id = Id+ "," + row.Cells[0].Text.ToString();
  }
 
  }
  if (hname != "" && rtype!= " ")
  {
  //Id=Id.TrimStart(',');
  hname = hname.TrimStart(',');
  rtype = rtype.TrimStart(',');
  Response.Redirect("room_type.aspx?d1=" + Id + "&d2=" + hname + "&d3=" +rtype);
  }
  }

room_type.aspx-

public void roominsrt()
  {
  aid = Request.QueryString["d1"].ToString();
  hnm = Request.QueryString["d2"];
  rtyp = Request.QueryString["d3"];
  string ConnectionServer = ConfigurationManager.AppSettings.Get("ConnectionServer");
  string sConn = clsdb.DecryptData(ConfigurationManager.AppSettings.Get("ConnectionString"));
  SqlConnection con = new SqlConnection("Server=" + ConnectionServer + ";" + sConn);
  con.Open();
  string sql = "update Infl_HotelInventory_RoomType set Aminities='" + aid + "' where hotel_name='"+ hnm + "' and RoomType = '"+ rtyp + "'";
  i_IBE.CommonDB.Execute(sql);
  con.Close();
  }

these are 2 related pages:- the error occurs in highlighted line which is. error is-
Object reference not set to an instance of an object.

please help me...whats wrong with the code..
thank you

Answers (1)