下面这段代码:
Dim UserName As String = e.Form.Controls("UserName").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
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
If dt Is Nothing Then
Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
Else
dr = dt.DataRows(0)
If e.Form.Controls("PassWord").Value = dr("Password") Then
_UserName = UserName
_UserGroup = dr("Group")
e.Form.Close
Else
Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
End If
现在遇到一个问题是 登录名字我一旦改成非Users 表里的记录 就会出现

此主题相关图片如下:1.jpg

我想弄成 不是users表里的 就会提示 无此用户 请重新输入的 字样!
不知道哪里的问题 这个数组!!
楼主:我想如果把用户帐号的组合框设成不准输入,只能选取的话,就不存在这个问题了,因为只有有效用户的帐号才能显示在组合框中,虽然说没有直接输入来得快,但安全很多,个人意见!
要知道 公司很多人呢 这个下拉框有多长。。。 我还准备用编号的方式呢 类似用户名0073
If dt Is Nothing Then
改为:
If dt.DataRows.Count = 0 Then