vb 修改密码 求高手帮忙修改一下错误, 是修改密码的代码,
vb修改密码求高手帮忙修改一下错误,是修改密码的代码,PrivateSubjcbutton1_Click()IfText1=""ThenMsgBox"请填写用户名!",v...
vb 修改密码 求高手帮忙修改一下错误, 是修改密码的代码,
Private Sub jcbutton1_Click()
If Text1 = "" Then
MsgBox "请填写用户名!", vbInformation + vbOKOnly, "提示"
Text1.SetFocus
Exit Sub
End If
If Text2 = "" Then
MsgBox "请填写旧密码!", vbInformation + vbOKOnly, "提示"
Text2.SetFocus
Exit Sub
End If
SQL = "select * from user where nam='" & Trim$(Text1.Text) & "'and " & "pwd='" & Trim$(Text2.Text) & "'"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
Adodc1.Refresh
If Adodc1.Recordset.RecordCount <> 0 Then
If Text3 = "" Then
MsgBox "请填写新密码!", vbInformation + vbOKOnly, "提示"
Text3.SetFocus
Exit Sub
End If
If Text4 = "" Then
MsgBox "请填写确认密码!", vbInformation + vbOKOnly, "提示"
Text4.SetFocus
Exit Sub
End If
If Text3.Text = Text4.Text Then
Adodc1.Recordset.Fields("pwd").Value = Text3.Text
Adodc1.Recordset.Update
Adodc1.Refresh
MsgBox "成功更改新密码!", vbInformation + vbOKOnly, "提示"
Else
MsgBox "两次输入的密码不一致,请重新输入!", vbExclamation + vbOKOnly, "提示"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
End If
Else
MsgBox "无效的用户名或密码", vbExclamation + vbOKOnly, "提示"
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\admin.mdb"
Adodc1.CursorLocation = adUseClient
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strDataSource
Adodc1.RecordSource = "select * from user"
Adodc1.Refresh
End Sub 展开
Private Sub jcbutton1_Click()
If Text1 = "" Then
MsgBox "请填写用户名!", vbInformation + vbOKOnly, "提示"
Text1.SetFocus
Exit Sub
End If
If Text2 = "" Then
MsgBox "请填写旧密码!", vbInformation + vbOKOnly, "提示"
Text2.SetFocus
Exit Sub
End If
SQL = "select * from user where nam='" & Trim$(Text1.Text) & "'and " & "pwd='" & Trim$(Text2.Text) & "'"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
Adodc1.Refresh
If Adodc1.Recordset.RecordCount <> 0 Then
If Text3 = "" Then
MsgBox "请填写新密码!", vbInformation + vbOKOnly, "提示"
Text3.SetFocus
Exit Sub
End If
If Text4 = "" Then
MsgBox "请填写确认密码!", vbInformation + vbOKOnly, "提示"
Text4.SetFocus
Exit Sub
End If
If Text3.Text = Text4.Text Then
Adodc1.Recordset.Fields("pwd").Value = Text3.Text
Adodc1.Recordset.Update
Adodc1.Refresh
MsgBox "成功更改新密码!", vbInformation + vbOKOnly, "提示"
Else
MsgBox "两次输入的密码不一致,请重新输入!", vbExclamation + vbOKOnly, "提示"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
End If
Else
MsgBox "无效的用户名或密码", vbExclamation + vbOKOnly, "提示"
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\admin.mdb"
Adodc1.CursorLocation = adUseClient
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strDataSource
Adodc1.RecordSource = "select * from user"
Adodc1.Refresh
End Sub 展开
3个回答
展开全部
SQL = "select * from [user] where nam='" & Trim$(Text1.Text) & "'and " & "pwd='" & Trim$(Text2.Text) & "'"
Adodc1.RecordSource = "select * from [user]"
user要加括号,它是access保留字。
Adodc1.RecordSource = "select * from [user]"
user要加括号,它是access保留字。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SQL = "select * from user where name='" & Trim$(Text1.Text) & "' and pwd='" & Trim$(Text2.Text) & "'"
更多追问追答
追问
不是name 是nam 字没有错 , 只出现sql语法错误
追答
私信留下Q,帮你解决
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
【SQL】 = "select * from user where nam='" & Trim$(Text1.Text) & "'and " & "pwd='" & Trim$(Text2.Text) & "'"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = 【strSQL】
检查比较【 】里面的内容,以及其他字段的拼法是否正确。
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = 【strSQL】
检查比较【 】里面的内容,以及其他字段的拼法是否正确。
更多追问追答
追答
服了,你竟然直接贴着用!
Dim strSQL as String
strSQL = "select * from user where nam='" & Trim$(Text1.Text) & "'and " & "pwd='" & Trim$(Text2.Text) & "'"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
《2个 strSQL 名称要一致即可》
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询