⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guestbook_add.aspx.cs

📁 不需要刷新网页,无限加长。源代码!!!!!!!!!
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
using System.Data.SqlClient;


public partial class guestBook_add : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnButton1_Click(object sender, EventArgs e)
    {
        //通过验证控件的验证
        if (Page.IsValid)
        {
            string sguestName = guestName.Text;
            string sguestContent = guestContent.Text;
            string sguestFrom = guestFrom.Text;


            string strConnection = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
            OleDbConnection objConnection = new OleDbConnection(strConnection);

            objConnection.Open();
            string strsql = "Insert Into tGuestBook(guestName,guestFrom,guestContent)Values('" + sguestName + "','" + sguestFrom + "','" + sguestContent + "' )";

            OleDbCommand objCommand = new OleDbCommand(strsql , objConnection);
            int ok=objCommand.ExecuteNonQuery();
            if (ok>0){
                addOK.Text = "添加成功";
            }
            objConnection.Close();



            //重定向到留言页面
            //Response.Redirect("index.aspx");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -