格莱美终身成就奖:VB高手进来帮忙看看偶滴程序的问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/24 05:52:08
小弟编写了个密码修改程序,可调试时总是写不到数据库中,好像是update句出了问题,代码如下
Dim con As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim m, t As Integer

Private Sub Command1_Click()
Set con = New ADODB.Connection
con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=db3.mdb"
con.Open

If Text1.Text <> "" Then
rst.Open "select username,password from yhdl where username='" & Trim(Text1.Text) & "' and password='" & Trim(Text2.Text) & "'", con, adOpenDynamic, adLockReadOnly

If rst.EOF = False And rst.BOF = False Then
m = MsgBox("确定修改?", vbOKCancel)
If m = 1 Then
If Text3 <> "" Then
rst.Close
On Error Resume Next
rst.Open "update yhdl set password='" & Trim(Text3.Text) & "'where username='" & Trim(Text1.Text) & "'", con
MsgBox "修改成功!"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
Unload Me
Else
MsgBox "为了数据库的安全,用户必须设定密码!", 48
Text3.SetFocus
Set rst = Nothing
End If
Else
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End If
Else
m = MsgBox("密码错误!请重试", 48)
Text2.Text = ""
Text2.SetFocus
Set rst = Nothing
End If
Else
MsgBox "请输入一个用户进行修改密码的操作!", 48
Set rst = Nothing
End If

End Sub