阅读背景:

更新查询在ASP.NET Web应用程序中不起作用

来源:互联网 
using System.Data.SqlClient;
using System.Data.Sql;

public partial class _Default : System.Web.UI.Page 
{


 SqlConnection con = new SqlConnection(@"Data Source=GAGAN-PC\SQLEXPRESS;Initial Catalog=update_test;Integrated Security=True");
    SqlCommand cmd;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void delete_button_Click(object sender, EventArgs e)
    {
        con.Open();
        cmd = new SqlCommand("delete from update_delete where id like'"+TextBox1.Text+"'",con);
        cmd.ExecuteNonQuery();
        Response.Write("Control reached.");
        con.Close();
        Response.Write("Data successfully deleted.");
    }
    protected void update_button_Click(object sender, EventArgs e)
    {
        con.Open();
        cmd = new SqlCommand("update update_delete set password ='"+TextBox3.Text+"' where id like'"+TextBox2+"'", con);
        cmd.ExecuteNonQuery();
        Response.Write("Control reached.");
        con.Close();
        Response.Write("Data successfully Updated.");
    }
}
using System.Data.SqlClient;
using System.Data.



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: