Dim UserName As String = e.Form.Controls("UserName").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
'cmd.Connection Name = "test2" 外部数据源
If UserName = "" Then
Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select * From {用户表} Where [用户名称] = '" & UserName & "'"
dt = cmd.ExecuteReader
If dt.DataRows.count = 0 Then
Messagebox.show("不存在此用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
dr = dt.DataRows(0)
If e.Form.Controls("PassWord").Value = dr("登录密码") Then
_UserName = UserName
_UserGroup = dr("分组名称")
e.Form.Close
For Each t As Table In Tables
t.Visible = True
t.AllowEdit = True
For Each c As Col In t.Cols
c.Visible = True
c.AllowEdit = True
Next
Next
Tables("授权表").Visible = (_UserGroup = "管理人员A")
For Each dr1 As DataRow In DataTables("授权表").Select("分组名称 = '" & _UserGroup & "'" )
If dr1.IsNull("列名称") Then
Tables(dr1("表窗名称")).Visible = Not dr1("不可见")
Tables(dr1("表窗名称")).AllowEdit = Not dr1("不可编辑")
Else
Tables(dr1("表窗名称")).Cols(dr1("列名称")).Visible = Not dr1("不可见")
Tables(dr1("表窗名称")).Cols(dr1("列名称")).AllowEdit = Not dr1("不可编辑")
End If
Next
If _usergroup <> "管理人员A" Then
Tables("授权表").Visible = False
Else
Tables("授权表").Visible = True
End If
Else
Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
好好看看这里:
http://www.foxtable.com/help/topics/1485.htm
知道这么找出出错的代码,这样就能更快地找出原因。
此外要知道: 重定向之后,新数据库中的表是空的,你得重新增加用户来测试。
[此贴子已经被作者于2012-10-18 14:42:34编辑过]