using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; namespace WebApplication3 { public partial class WebForm1 : System.Web.UI.Page { string data; protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { data = TextBox1.Text; using (SqlConnection con = new SqlConnection("initial catalog=users;data source=.; integrated security=sspi")) { if (TextBox1.Text != "") { con.Open(); SqlCommand cmd = new SqlCommand("insert into dbo.names values(@data)", con); SqlParameter dataparam = cmd.Parameters.Add("@data", System.Data.SqlDbType.VarChar); dataparam.Value = data; cmd.ExecuteNonQuery(); TextBox1.Text = ""; } } } } }
protected void Button1_Click(object sender, EventArgs e)
if(!Page.IsPostBack) { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)