//text4為用戶名,text1為舊的密碼,text2為新的密碼,text3為確認密碼,
Private Sub Command1_Click()
Dim txtsql As String
Private Sub ok_Click()
If Trim(Text4.Text) = "" Then
MsgBox "用戶名不能為空!", vbExclamation + vbOKOnly, "警告"
Text4.SetFocus
Exit Sub
End If
If Trim(Text2.Text) <> Trim(Text3.Text) Then
MsgBox "兩次密碼輸入不相同!", , "密碼"
Exit Sub
End If
If Trim(Text3.Text) = "" Or Trim(Text1.Text) = "" Or Trim(Text2.Text) = "" Then
MsgBox "用戶名或密碼不能為空!", vbExclamation + vbOKOnly, "警告"
Exit Sub
End If
Dim mrc As ADODB.Recordset
mrc.Open txtsql = "select * from users where username='" & Text4.Text & "'"
Set mrc = ExecuteSQL(txtsql)
mrc.AddNew
If mrc.RecordCount = 0 Then MsgBox "用戶不存在!", vbExclamation, "用戶"
Exit Sub
End If
mrc.Fields("userpwd") = Trim(Text1.Text)
mrc.UpdateBatch
MsgBox "密碼更改成功!", , "成功"
Text4.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
uj5u.com熱心網友回復:
1. Private Sub Command1_Click() 或 Private Sub ok_Click()這其中有一行是多余的。
2. If mrc.RecordCount = 0 Then 后面 MsgBox 這句要換行寫,要不然代碼語法結構就錯了。
uj5u.com熱心網友回復:
這里面資料庫操作的代碼有沒有問題我不清楚。無”實際環境“來判斷,有問題也不是能猜出來的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/99708.html
標籤:網絡編程
上一篇:報錯求助
下一篇:剛宣告了個變數,我錯哪兒了?
