asp.net添加数据代码高手们帮我看看谢谢了

来源:百度知道 编辑:UC知道 时间:2024/05/15 10:06:05
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
}
private void InitializeComponent()
{
this.TextBox1.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
SqlConnection con = new SqlConnection("server=;uid=sa;pwd=;database=aaa");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
string test= this.TextBox1.Text;
cmd.CommandText = "insert into like valuse ('"+id+"')";
con.Close();
}
private void TextBox1_TextCh

缺少
cmd.ExecuteNonQuery();执行命令……
代码太丑了!不要这样使用SqlCommand,写到SqlCommand.Parameters.Add("@P1",SqlDbType.Int)中……
汗……留下邮箱,送你本教程!你这样写代码,后面会写不动的……