luru.aspx.cs

来自「学籍管理系统能够完成对学生信息的填加,删除,修改等功能.」· CS 代码 · 共 45 行

CS
45
字号
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

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

    }
   
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        try
    {
        SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data source=.;Database=xueji;Integrated Security=SSPI";
            conn.Open();
            String sql = "insert into student(id,name,sex,adress,birth,sfid,adept,subject,class1,email,tel,beizhu)" + "values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + RadioButtonList1.SelectedValue + "','" + TextBox3.Text + "','" + DropDownList1.SelectedValue + DropDownList2.SelectedValue + DropDownList3.SelectedValue + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox10.Text + "','" + TextBox8.Text + "','" + TextBox12.Text + "')";
            SqlCommand comm = new SqlCommand(sql, conn);
            int a = comm.ExecuteNonQuery();
            if (a!= 0)
               Label6.Text = "成功录入";
            conn.Close();
            }
          catch
            {
              
              Response.Write("<script>alert('用户已存在!')</script>");
          }
   }


   
}

⌨️ 快捷键说明

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