?? 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 + -