Afterload 代码如下:
Dim UserName As String
Dim UserGroup As String
Dim PassWord 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
End If
e.Form.Text = e.Form.Text & "-" & UserName
cmd.C
cmd.CommandText = "Select * From {Users} Where [Name] = '" & UserName & "'"
dt = cmd.ExecuteReader
If dt.DataRows.Count = 1 Then
e.Form.Controls("UserName").Value = UserName
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
Dim cmx As New SQLCommand
Dim dx As DataTable
cmd.C
cmx.CommandText = "SELECT DISTINCT Group From {users}"
dx = cmx.ExecuteReader
e.Form.controls("usergroup").Combolist = dx.GetComboListString("Group")
出错窗口如下:
此主题相关图片如下:1.jpg

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

查了半天没查出毛病 在哪里 !
[此贴子已经被作者于2011-11-2 22:37:03编辑过]