Dim UserName As String = e.Form.Controls("UserName").Value Dim UserGroup As String = e.Form.Controls("UserGroup").Value Dim PassWord As String = e.Form.Controls("PassWord").Value Dim OldUserName As String Dim dt As DataTable Dim dr As DataRow Dim cmd As New SQLCommand cmd.C cmd.CommandText = "Select * From {Users} Where [Name] = '" & UserName & "'" dt = cmd.ExecuteReader dr = dt.DataRows(0) If e.Form.Controls("OldPassWord").Value = dr("Password") Then cmd.CommandText = cmd.CommandText & "', [Password] = '" & Password & "' Where [Name]= '" & OldUserName & "'" If cmd.ExecuteNonQuery = 1 Then '返回1表示更改成功 Messagebox.show("密码更改成功,切记新设密码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) End If Else Messagebox.show("老密码错误,更改失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) End If
|