📄 form4.frm
字号:
VERSION 5.00
Begin VB.Form Form4
Caption = "修改密码"
ClientHeight = 2850
ClientLeft = 60
ClientTop = 345
ClientWidth = 2580
Icon = "Form4.frx":0000
LinkTopic = "Form4"
ScaleHeight = 2850
ScaleWidth = 2580
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text3
Height = 375
Left = 1200
TabIndex = 7
Top = 1440
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 1320
TabIndex = 5
Top = 2160
Width = 975
End
Begin VB.CommandButton Command1
Caption = "修改密码"
Height = 375
Left = 240
TabIndex = 2
Top = 2160
Width = 975
End
Begin VB.TextBox Text1
Height = 375
Left = 1200
TabIndex = 1
Top = 240
Width = 1095
End
Begin VB.TextBox Text2
Height = 375
Left = 1200
TabIndex = 0
Top = 840
Width = 1095
End
Begin VB.Label Label3
Caption = "再次输入:"
Height = 255
Left = 240
TabIndex = 6
Top = 1560
Width = 855
End
Begin VB.Label Label1
Caption = "用 户 名:"
Height = 255
Left = 240
TabIndex = 4
Top = 360
Width = 735
End
Begin VB.Label Label2
Caption = "新 密 码:"
Height = 255
Left = 240
TabIndex = 3
Top = 960
Width = 855
End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim gAdoConn As New ADODB.Connection
Dim gStrConn As String
'创建对象
Set gAdoConn = New ADODB.Connection
'定义Connection对象连接参数
'provider参数指定连接数据库驱动,data bank_zhhao参数指定数据库名称
gStrConn = "driver={SQL Server};" & _
"server=61.174.60.164;uid=jincaia;pwd=meilishijie;database=jincai"
'使用连接参数,建立数据库连接
gAdoConn.Open gStrConn
Dim adoSetMima As ADODB.Recordset
Dim strSQL As String
Dim blnChangeAble As Boolean
If Text1.Text <> "" And Text2.Text <> "" And (Text2.Text = Text3.Text) Then
blnChangeAble = True
Else
MsgBox "两次密码输入一致", vbOKOnly, "修改密码出错"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End If
If blnChangeAble Then
strSQL = "select name,password from users where name = '" & Text1.Text & "'"
Set adoSetMima = New ADODB.Recordset
adoSetMima.Open strSQL, gAdoConn, adOpenKeyset, adLockBatchOptimistic '打开记录集,以备修改密码
If adoSetMima.BOF = False Then
adoSetMima!password = Text2.Text
adoSetMima.UpdateBatch
MsgBox "修改密码成功!", vbOKOnly, "修改密码"
Else
MsgBox "没有找到用户,请重新输入!", vbOKOnly, "错误"
'清空各文本框,以便重新输入
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End If
adoSetMima.Close ' 关闭记录集
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -