Torna al Thread

protected void Cancellati_Click(object sender, EventArgs e) { string nome = txtNomeE.Text; string cognome = txtCognomeE.Text; string datan = txtDataNE.Text; string luogon = txtLuogoNE.Text; string ruolo = dpdRuolo.SelectedItem.Text; string query=""; string query1; SqlCommand comando; SqlConnection cn; cn = new SqlConnection("Data Source=NBD820-03;Initial Catalog=AdventureWorks;Integrated Security=True"); cn.Open(); query1 = "IF EXISTS (SELECT * FROM AnagraficaStagisti WHERE Nome LIKE '%" + nome + "%' AND Cognome LIKE '%" + cognome + "%' AND DataNascita LIKE '%" + datan + "%' AND LuogoNascita LIKE '%" + luogon + "%' AND Ruolo LIKE '%" + ruolo + "%')"; if (query1 != "") { query = "DELETE FROM AnagraficaStagisti WHERE Nome LIKE '%" + nome + "%' AND Cognome LIKE '%" + cognome + "%' AND DataNascita LIKE '%" + datan + "%' AND LuogoNascita LIKE '%" + luogon + "%' AND Ruolo LIKE '%" + ruolo + "%'"; } comando = new SqlCommand(query, cn); comando.ExecuteNonQuery(); cn.Close(); if (query != "") { this.ClientScript.RegisterStartupScript(this.GetType(), "Some Title", "<script language=\"javaScript\">" + "alert('Cancellazione effettuata con successo!');" + "window.location.href='Home.aspx';" + "<" + "/script>"); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "Some Title", "<script language=\"javaScript\">" + "alert('Dati errati riprovare');" + "window.location.href='Eliminadati.aspx';" + "<" + "/script>"); } }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5