protected void Page_Load(object sender, EventArgs e) { if (Session["current_user"] == null) { Response.Redirect("login.aspx"); } client = new ServiceReference2.Service1Client(); int id = Int32.Parse(Request.Cookies["pid"].Value); dest = client.getPlace(id); }
public void getPlace() { List <Client.ServiceReference2.tour> users = new List <Client.ServiceReference2.tour>(); Client.ServiceReference2.tour u; SqlConnection con = null; SqlCommand cmd = null; try { con = new SqlConnection(); con.ConnectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Database;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; using (con) { //Label1.Text += fplaces.Count; for (int i = 0; i < fplaces.Count; i++) { string command = "select * from Place where placeid= '" + fplaces[i] + "'"; cmd = new SqlCommand(command, con); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { u = new Client.ServiceReference2.tour(); //Label2.Text += rdr["placeid"]; u.placeid = (int)rdr["placeid"]; u.name = rdr["name"].ToString(); u.desc = rdr["description"].ToString(); u.price = rdr["price"].ToString(); u.imagepath = rdr["imagepath"].ToString(); places.Add(u); } con.Close(); System.Console.WriteLine(users); } } } catch (Exception err) { } finally { con.Close(); } }