狐爸,我设计的登录窗口,然后连接了sql数据库。当输入一个数据库里没有的姓名的时候,会提示以下错误,我想问下,该怎么修改呢?
此主题相关图片如下:未命名.jpg
登录界面的确定代码如下:
Dim UserName As String = e.Form.Controls("UserName").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
Dim i As Integer
cmd.C
If UserName = "" Then
Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select * From {Users} Where [Name] = '" & UserName & "'"
dt = cmd.ExecuteReader
i = cmd.ExecuteScalar
dr = dt.DataRows(0)
If e.Form.Controls("PassWord").Value = dr("Password") Then
_UserName = UserName
_UserGroup = dr("Group")
e.Form.Close
StatusBar.Message2 = "当前用户" & _usergroup & "-" & _username & "☆"
Else
Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If