📄 updates.cs
字号:
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 updates : Form
{
SqlConnection dbconn;//连接类
SqlDataAdapter dbda;//适配器:连接数据库的窗口
SqlCommand dbcom;//命令集
DataSet rs;//数据集:相当于在存表
public updates()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void buttonok_Click(object sender, EventArgs e)
{
dbconn = new SqlConnection();
dbconn.ConnectionString = "user id=sa;data source=localhost;integrated security=false;initial catalog=学生数据库1";
dbconn.Open();
dbda = new SqlDataAdapter("select * from login", dbconn);
rs = new DataSet();
dbda.Fill(rs);
dbcom = new SqlCommand();
if (textBoxoldpwd.Text != "" && textBoxnewpwd1.Text != "" && textBoxnewpwd2.Text != "")
{
if (textBoxnewpwd1.Text == textBoxnewpwd2.Text)
{
dbcom.CommandText = "update login set 密码='" + textBoxnewpwd1.Text + "'where 密码 ='" + textBoxoldpwd.Text + "'";
dbcom.Connection = dbconn;
dbcom.ExecuteNonQuery();
MessageBox.Show("密码修改成功");
this.Close();
}
else
{ MessageBox.Show("两次的密码不相同!"); }
}else
MessageBox.Show("密码不能为空!");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -