📄 form5.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 WindowsApplication1
{
public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
string str1 = this.textBox1.Text;
string str2 = this.textBox2.Text;
bool bCheck = true;
if (!str1.Equals(str2))
{
MessageBox.Show("两次输入的密码不相同,请重新输入!");
bCheck = false;
this.textBox1.Focus();
}
if (bCheck)
{
SqlConnection conn = new SqlConnection(@"Data Source=.;Initial Catalog=tushu; Integrated Security=True");
try
{
conn.Open();
string sql = "update usertable set password=@pwd where userna='sunyi'";
SqlCommand cmmd = new SqlCommand(sql, conn);
SqlParameter pPwd = new SqlParameter("@pwd", SqlDbType.VarChar);
pPwd.Value = str1;
cmmd.Parameters.Add(pPwd);
if (cmmd.ExecuteNonQuery()==1)
{
MessageBox.Show("密码修改成功");
}
else
{
MessageBox.Show("密码修改失败");
}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
finally
{
conn.Close();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -