Default.aspx.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

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

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(access.sqlconn); //创建数据链接并生成对象使用
        try                                                     //检查
        {
            conn.Open();                                        //打开数据库
            string strcmd = "insert into reg values('"          //定义数据插入字段和值
                + TextBox1.Text.Trim() + "','"
                + TextBox2.Text.Trim() + "','"
                + TextBox3.Text.Trim() + "','"
                + TextBox4.Text.Trim() + "','"
                + TextBox5.Text.Trim() + "','"
                + DropDownList1.SelectedItem.Text.Trim() + "','"
                + TextBox6.Text.Trim() + "','"
                + TextBox7.Text.Trim() + "',"
                + "getdate()"
                + ")"
                ;
            SqlCommand comm = new SqlCommand(strcmd, conn);     //执行数据插入命令
            int nResult;                                        //定义返回
            nResult = comm.ExecuteNonQuery();                   //返回结果
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('" + TextBox1.Text + TextBox2.Text + ",用户,恭喜注册成功!')</script>");
        }
        catch (SqlException ex)
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('" + ex.Message + "')</script>");
        }
        finally
        {
            conn.Close();
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。