应用程序的登陆框,老是提示用户不存在,大虾帮忙看看
海大富运动 2005-04-05 09:27:51 Private Sub BtOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtOK.Click
Try
Me.Text = "正在验证...."
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Dim comstr As String
Dim mydataset As New DataSet
comstr = "select 密码 from 一般用户 where 用户名='" & Trim(TxtUserName.Text) & "'"
mydataset.Clear()
Dim adapter As New SqlDataAdapter(comstr, SqlConnection1)
adapter.Fill(mydataset, "table1") '判断密码是否正确
If mydataset.Tables("table1").Rows(0).Item(0) = Trim(TxtPassword.Text) Then
'如果查找不到任何行,则此处出现异常
UserInf(0) = Trim(TxtUserName.Text)
UserInf(1) = CmbPurview.Text
If CmbPurview.Text <> "管理员" Then
With ob_MainForm
.BtGoods.Visible = False
.BtFinance.Visible = False
.BtEmployee.Visible = False
.BtSaleHistory.Visible = False
End With
End If
ob_MainForm.Show()
Me.Hide()
Else
MsgBox("密码错误!")
TxtPassword.Text = ""
Me.Text = ""
Me.Cursor = System.Windows.Forms.Cursors.Arrow
TxtPassword.Focus()
End If
Catch ex As Exception
MsgBox("用户不存在!", MsgBoxStyle.OKOnly, "提示")
TxtUserName.Text = ""
TxtPassword.Text = ""
Me.Text = ""
Me.Cursor = System.Windows.Forms.Cursors.Arrow
End Try
End Sub
数据库的结构是 用户名 密码 权限
admin 123456