protected void FiltroIps(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlServer"].ToString())) { using (SqlCommand cmd = new SqlCommand("Select ID As 'ID', Nombre As 'Nombre' , IP As 'IP', Tipo as 'Type' from [LUIS AGUILAR].[ADESCPDB].[dbo].[tMachines] where Nombre LIKE'" + TextBox1.Text + "%'")) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); TablaIp.DataSource = dt; TablaIp.DataBind(); } } } } }
private void BindGrid() { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlServer"].ToString())) { using (SqlCommand cmd = new SqlCommand("Select ID As 'ID', Nombre As 'Nombre' , IP As 'IP', Tipo as 'Type' from [LUIS AGUILAR].[ADESCPDB].[dbo].[tMachines] ")) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); TablaIp.DataSource = dt; TablaIp.DataBind(); //ajuas.DataSource = dt; // ajuas.DataBind(); } } } } using (SqlConnection cons = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlServer"].ToString())) { using (SqlCommand cmd = new SqlCommand("Select I.id_IP As 'ID', M.nombre As 'Nombre', M.ip as 'IP', m.tipo As 'Type' FROM IPS I inner join[LUIS AGUILAR].[ADESCPDB].[dbo].[tMachines] M on I.ID_Machine = M.ID where id_HRI = '" + Request.QueryString["Parameter"].ToString() + "'")) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = cons; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); gdvIpA.DataSource = dt; gdvIpA.DataBind(); } } } } using (SqlConnection cons = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlServer"].ToString())) { using (SqlCommand cmd = new SqlCommand("select ID As 'ID', Nombre As 'Nombre' from [LUIS AGUILAR].[ADESCPDB].[dbo].[EquipESP]")) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = cons; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); GdvEsp.DataSource = dt; GdvEsp.DataBind(); } } } } using (SqlConnection cons = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlServer"].ToString())) { using (SqlCommand cmd = new SqlCommand("Select I.id_IP As 'ID', M.nombre As 'Nombre' FROM [LUIS AGUILAR].[ADESCPDB].[dbo].[IPS2] I inner join [LUIS AGUILAR].[ADESCPDB].[dbo].[EquipESP] M on I.ID_Machine = M.ID where id_HRI = '" + Request.QueryString["Parameter"].ToString() + "'")) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = cons; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); gdvEspAs.DataSource = dt; gdvEspAs.DataBind(); } } } } // try // { // con.Open(); // String query = "Select id_user As 'id', n_user As 'Usuario', n_pass As 'Contraseña' from dbo.users "; // SqlCommand cmd = new SqlCommand(query, con); // SqlDataReader rdr = cmd.ExecuteReader(); // gdvusuarios.DataSource = rdr; // gdvusuarios.DataBind(); // gdvusuarios.Columns[1].HeaderText = "TextoAMostrarEnLaCabecera"; // } // catch (Exception ex) // { // Console.WriteLine("algo anda mal"); // } // finally // { // con.Close(); // } }