Torna al Thread

protected void Button1_Click(object sender, EventArgs e) { String str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("/App_Data/mailing_list.mdb"); OleDbConnection cn = new OleDbConnection(str); cn.Open(); string nome = this.TextBox1.Text; string mail = this.TextBox2.Text; string stato = ""; if (this.RadioButtonList1.SelectedValue.Equals("Iscriviti")) { stato = "si"; try { string sql = "INSERT INTO lista ([nome],[email],[attivo],[data_inserimento]) VALUES (" + nome + "," + mail + ",si," + System.DateTime.Now + ")"; OleDbCommand cmd = new OleDbCommand(sql, cn); this.query.Text = str; cmd.ExecuteNonQuery(); this.verifica_ml.Text = "Email inserita"; } catch (Exception ex) { this.verifica_ml.Text = "Errore: " + ex.ToString(); } } if (this.RadioButtonList1.SelectedIndex.Equals("Cancellati")) { } cn.Close(); }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5