ASP 用GridView控件连接SQL Server数据库(3)
cmd.Parameters["@_leibie"].Value = TextBox2.Text.Trim();
cmd.Parameters.Add("@_timu", SqlDbType.VarChar);
cmd.Parameters["@_timu"].Value = TextBox3.Text.Trim();
cmd.Parameters.Add("@_neirong", SqlDbType.VarChar);
cmd.Parameters["@_neirong"].Value = TextBox4.Text.Trim();
con.Open();
cmd.ExecuteNonQuery();
GridViewBind();
}
}
protected void 删除新闻_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{
this.Page.RegisterStartupScript("ss", "<script>alert('请输入你想删除的编号')</script>");
}
else
{
SqlConnection con = new SqlConnection(ConfigurationManager.
ConnectionStrings["connection"].ConnectionString);
string delete = "delete news from news where 新闻编号='" + TextBox1.Text + "'";
SqlCommand com = new SqlCommand(delete, con);
con.Open();
com.ExecuteNonQuery();
con.Close();
GridViewBind();
}
}
protected void 修改新闻_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{
this.Page.RegisterStartupScript("ss", "<script>alert('请输入你要删除的编号')</script>");
相关新闻>>
- 发表评论
-
- 最新评论 更多>>