增删改查小案例

修改简介
protected void BtnSubmit_Click(object sender, EventArgs e)
    {
            MyConn = DB.CreateDB();
            MyConn.Open();
            string content =FunStr(this.TxtContent.Text);
            OleDbCommand cmd1 = new OleDbCommand("Update about set About='" + content + "'", MyConn);
            cmd1.ExecuteNonQuery();
            Response.Write("<script>alert('企业简介更新成功');window.location.href='Admin_About.aspx'</script>");
            MyConn.Close();
    }


添加新闻

 

if (this.IsValid)
        {
            string title = Request["TxtTitle"].ToString();
            string addurl = Request["TxtAddurl"].ToString();
            OleDbConnection myconn = DB.CreateDB();
            myconn.Open();
            OleDbCommand cmd = new OleDbCommand("insert into link(title,addurl) values('" + title + "','" + addurl + "')", myconn);
            cmd.ExecuteNonQuery();
            Response.Write("<script language=javascript>window.alert('添加成功!');window.location.href='Admin_LinkAdd.aspx';</script>");
            myconn.Close();
        }


你可能感兴趣的:(String,object,cmd,insert)