老师您好! 我想采用“帮助”中,”自定义用户与权限管理之一”的例子,制作一个先登录后调用项目程序的界面,在运行”增加用户窗口”中,出现了如下错误:
此主题相关图片如下:7608511909ddad43dd2ef8d13e69309.jpg
不知道怎么处理了,请指教!谢谢!
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 cmd As New S QLCommand
cmd.C
If UserName = "" OrElse UserGroup = "" Then
Messagebox.show("请输入用户名和用户分组!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "S elect Count(*) From {Users} Where Name = '" & UserName & "'"
If cmd.ExecuteScalar > 0 Then
Messagebox.show("增加用户失败,已经能存在同名用户!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Insert Into {Users} ([Name],[Group],[Password]) Values ('"
cmd.CommandText = cmd.CommandText & UserName & "','" & UserGroup & "','" & Password & "')"
If cmd.ExecuteNonQuery = 1 Then '返回1表示增加成功
If Forms("用户管理").Opened Then
With Forms("用户管理").Controls("ListBox1")
.Items.Add(UserName)
.SelectedIndex = .Items.Count - 1
End With
End If
e.Form.Close()
End If