我在更改用户的窗口中添加了“真实姓名”这个文本框,在更改用户的窗口的AfterLoad中代码如下:
e.Form.AcceptButton = "Button2"
e.Form.AcceptButton = "Button1"
Dim UserName As String
Dim UserGroup As String
Dim PassWord As String
Dim TextBox1 As String
Dim cmd As New SQLCommand
Dim dt As DataTable
If Forms("用户管理").Opened Then
UserName = Forms("用户管理").Controls("ListBox1").SelectedItem
Else
UserName = _UserName '_UserName为全局变量,用于保存当前用户名
e.Form.Controls("UserName").Enabled = False
e.Form.Controls("UserGroup").Enabled = False
e.Form.Controls("TextBox1").Enabled = False
End If
e.Form.Text = e.Form.Text & "-" & UserName
cmd.C
cmd.CommandText = "Select * From {Users} Where [Name] = '" & UserName & "'"
cmd.CommandText = "Select * From {Users} Where [Name1] = '" & TextBox1 & "'"
dt = cmd.ExecuteReader
If dt.DataRows.Count = 1 Then
e.Form.Controls("UserName").Value = UserName
e.Form.Controls("TextBox1").Value = TextBox1
e.Form.Controls("UserGroup").Value = dt.DataRows(0)("Group")
e.Form.Controls("PassWord").Value = dt.DataRows(0)("PassWord")
Else
MessageBox.Show("用户不存在或者已经被删除!","提示",MessageBoxButtons.OK)
e.Form.Close()
End If
此主题相关图片如下:1.png
点“更改用户”时为什么会提示:“用户不存在或者已经被删除”???
此主题相关图片如下:2.png
[此贴子已经被作者于2014-11-17 17:55:33编辑过]