📄 okpwdchange.aspx.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Partial Class pwdChange
Inherits System.Web.UI.Page
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim strsql As String
Dim a As Integer
If Trim(DropDownList1.SelectedItem.Text) = "教师" Then
a = 1
strsql = "select * from 老师表 where 教师编号='" & Trim(TextBox1.Text) & "'and 密码='" & Trim(TextBox2.Text) & "'"
ElseIf Trim(DropDownList1.SelectedItem.Text) = "学生" Then
a = 2
strsql = "select * from 学生表 where 学号='" & Trim(TextBox1.Text) & "'and 密码='" & Trim(TextBox2.Text) & "'"
Else : a = 3
strsql = "select * from 管理员表 where 编号='" & Trim(TextBox1.Text) & "'and 密码='" & Trim(TextBox2.Text) & "'"
End If
Dim coon As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
Dim cmd As New SqlCommand(strsql, coon)
coon.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
If dr.Read() Then
Dim strsql1 As String
If a = 1 Then
strsql1 = "Update 老师表 set 密码 ='" & TextBox4.Text & "' where 教师编号= '" & TextBox1.Text & "' "
ElseIf a = 2 Then
strsql1 = "Update 学生表 set 密码= '" & TextBox4.Text & "' where 学号= '" & TextBox1.Text & "' "
Else
strsql1 = "Update 管理员表 set 密码= '" & TextBox4.Text & "' where 编号= '" & TextBox1.Text & "' "
End If
Dim conn As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
Dim cmd3 As New SqlCommand(strsql1, conn)
conn.Open()
cmd3.ExecuteNonQuery()
coon.Close()
Label6.Text = " 修改成功!"
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox1.Focus()
Else : Label6.Text = "用户名或密码错误请重试!"
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox1.Focus()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -