deleteuser.cs

来自「不错的班级管理系统」· CS 代码 · 共 47 行

CS
47
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace _7计应的班级管理系统
{
    public partial class deleteuser : Form
    {
        public deleteuser()
        {
            InitializeComponent();
        }

        private void buttonok_Click(object sender, EventArgs e)
        {
            string strconn = "user id=sa;data source=localhost;integrated security=false;initial catalog=学生数据库1";
            string strsql = "delete from login where 用户名='" + textBoxuid.Text.Trim() + "'";
            SqlConnection conn = new SqlConnection(strconn);
            try
            {
                //当没有此用户时...(还没写-_-||)
                SqlCommand cmd = new SqlCommand(strsql, conn);
                conn.Open();
                cmd.ExecuteNonQuery();
                MessageBox.Show("删除成功!");
            }
            catch (SqlException se)
            {
                MessageBox.Show(se.Message);
            }
            finally
            {
                conn.Close();
            }
        }

        private void buttonexit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

⌨️ 快捷键说明

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