“GlobalConst”的类型初始值设定项引发异常
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
''''如果是为响应客户端回发而加载该页,则为 true;否则为 false。
If Not Page.IsPostBack Then
If Not Session("UserInfo") Is Nothing Then
Me.Response.Redirect("Default.aspx", True)
Else
If Not isEnter(Me) Is Nothing Then
Me.Response.Redirect("Default.aspx", True)
End If
End If
End If
End Sub
当执行到这里的时候If Not isEnter(Me) Is Nothing Then 会报出错误“GlobalConst”的类型初始值设定项引发异常,其中isenter是GlobalConst(Module)的一个函数。
Function isEnter(ByVal pPage As System.Web.UI.Page, Optional ByVal Userid As String = "")
Dim oUserInfo As New UserInfo
Dim strip As String = pPage.Request.ServerVariables("REMOTE_ADDR")
Dim strjqm As String = ""
'Try
' strjqm = Net.Dns.GetHostEntry(strip).HostName
'Catch ex As Exception
' strjqm = strip
'End Try
'Try
' If strip = "127.0.0.1" Then
' strip = Net.Dns.GetHostAddresses(strjqm)(0).ToString
' End If
'Catch ex As Exception
' strip = strjqm
'End Try
Dim isDBm As New DBManager.PropOracleDbManager
isDBm.DatabaseType = DBManager.enumDatabaseType.propDatabaseOracle
isDBm.ConnectionArgs = getStrCnn()
Try
If isDBm.GetConn.State = ConnectionState.Closed Then
isDBm.GetConn()
End If
Dim isSql As String = ""
If Userid <> "" Then
isSql = "select A.YHZH,A.YHMC,A.SSDWBS,A.ISADMIN,A.DZYJ,A.LXDH,to_char(entertime,'YYYY-MM-DD HH24:MM:SS') AS entertime from a4_sys_userinfo a, a4_sys_enter b " _
& " Where a.YHZH=b.enteruserid and to_char(Sysdate,'yymmddhh24mi')-to_char(entertime,'yymmddhh24mi')<120 and isstate=1" _
& " and enterjqm='" & strip & "'and enteruserid='" & Userid & "'"
Else
isSql = "select A.YHZH,A.YHMC,A.SSDWBS,A.ISADMIN,A.DZYJ,A.LXDH ,to_char(entertime,'YYYY-MM-DD HH24:MM:SS') AS entertime from a4_sys_userinfo a, a4_sys_enter b " _
& " Where a.YHZH=b.enteruserid and to_char(Sysdate,'yymmddhh24mi')-to_char(entertime,'yymmddhh24mi')<120 and isstate=1 " _
& " and enterjqm='" & strip & "' and enterip='" & strip & "'"
End If
Dim oRd As Data.OracleClient.OracleDataReader
oRd = isDBm.ExecuteReader(isSql)
If oRd Is Nothing Then
Return Nothing
End If
If oRd.HasRows Then
While oRd.Read
If Not oRd.IsDBNull(0) Then
oUserInfo.userID = oRd.Item(0).ToString
Else
oUserInfo.userID = ""
End If
If Not oRd.IsDBNull(1) Then
oUserInfo.userName = oRd.Item(1).ToString
Else
oUserInfo.userName = ""
End If
If Not oRd.IsDBNull(2) Then
oUserInfo.userOrg = oRd.Item(2).ToString
Else
oUserInfo.userOrg = ""
End If
If Not oRd.IsDBNull(3) Then
oUserInfo.isAdmin = oRd.Item(3).ToString
Else
oUserInfo.isAdmin = 0
End If
If Not oRd.IsDBNull(4) Then
oUserInfo.userEmail = oRd.Item(4).ToString
Else
oUserInfo.userEmail = ""
End If
If Not oRd.IsDBNull(5) Then
oUserInfo.userTel = oRd.Item(5).ToString
Else
oUserInfo.userTel = ""
End If
If Not oRd.IsDBNull(6) Then
oUserInfo.EnterTime = oRd.Item(6).ToString
Else
oUserInfo.EnterTime = Now
End If
End While
pPage.Session("UserInfo") = oUserInfo
Return oUserInfo
Else
oUserInfo = Nothing
Return Nothing
End If
Catch ex As Exception
Return Nothing
Finally
isDBm.CloseConn()
isDBm = Nothing
End Try
End Function
''''如果是为响应客户端回发而加载该页,则为 true;否则为 false。
If Not Page.IsPostBack Then
If Not Session("UserInfo") Is Nothing Then
Me.Response.Redirect("Default.aspx", True)
Else
If Not isEnter(Me) Is Nothing Then
Me.Response.Redirect("Default.aspx", True)
End If
End If
End If
End Sub
当执行到这里的时候If Not isEnter(Me) Is Nothing Then 会报出错误“GlobalConst”的类型初始值设定项引发异常,其中isenter是GlobalConst(Module)的一个函数。
Function isEnter(ByVal pPage As System.Web.UI.Page, Optional ByVal Userid As String = "")
Dim oUserInfo As New UserInfo
Dim strip As String = pPage.Request.ServerVariables("REMOTE_ADDR")
Dim strjqm As String = ""
'Try
' strjqm = Net.Dns.GetHostEntry(strip).HostName
'Catch ex As Exception
' strjqm = strip
'End Try
'Try
' If strip = "127.0.0.1" Then
' strip = Net.Dns.GetHostAddresses(strjqm)(0).ToString
' End If
'Catch ex As Exception
' strip = strjqm
'End Try
Dim isDBm As New DBManager.PropOracleDbManager
isDBm.DatabaseType = DBManager.enumDatabaseType.propDatabaseOracle
isDBm.ConnectionArgs = getStrCnn()
Try
If isDBm.GetConn.State = ConnectionState.Closed Then
isDBm.GetConn()
End If
Dim isSql As String = ""
If Userid <> "" Then
isSql = "select A.YHZH,A.YHMC,A.SSDWBS,A.ISADMIN,A.DZYJ,A.LXDH,to_char(entertime,'YYYY-MM-DD HH24:MM:SS') AS entertime from a4_sys_userinfo a, a4_sys_enter b " _
& " Where a.YHZH=b.enteruserid and to_char(Sysdate,'yymmddhh24mi')-to_char(entertime,'yymmddhh24mi')<120 and isstate=1" _
& " and enterjqm='" & strip & "'and enteruserid='" & Userid & "'"
Else
isSql = "select A.YHZH,A.YHMC,A.SSDWBS,A.ISADMIN,A.DZYJ,A.LXDH ,to_char(entertime,'YYYY-MM-DD HH24:MM:SS') AS entertime from a4_sys_userinfo a, a4_sys_enter b " _
& " Where a.YHZH=b.enteruserid and to_char(Sysdate,'yymmddhh24mi')-to_char(entertime,'yymmddhh24mi')<120 and isstate=1 " _
& " and enterjqm='" & strip & "' and enterip='" & strip & "'"
End If
Dim oRd As Data.OracleClient.OracleDataReader
oRd = isDBm.ExecuteReader(isSql)
If oRd Is Nothing Then
Return Nothing
End If
If oRd.HasRows Then
While oRd.Read
If Not oRd.IsDBNull(0) Then
oUserInfo.userID = oRd.Item(0).ToString
Else
oUserInfo.userID = ""
End If
If Not oRd.IsDBNull(1) Then
oUserInfo.userName = oRd.Item(1).ToString
Else
oUserInfo.userName = ""
End If
If Not oRd.IsDBNull(2) Then
oUserInfo.userOrg = oRd.Item(2).ToString
Else
oUserInfo.userOrg = ""
End If
If Not oRd.IsDBNull(3) Then
oUserInfo.isAdmin = oRd.Item(3).ToString
Else
oUserInfo.isAdmin = 0
End If
If Not oRd.IsDBNull(4) Then
oUserInfo.userEmail = oRd.Item(4).ToString
Else
oUserInfo.userEmail = ""
End If
If Not oRd.IsDBNull(5) Then
oUserInfo.userTel = oRd.Item(5).ToString
Else
oUserInfo.userTel = ""
End If
If Not oRd.IsDBNull(6) Then
oUserInfo.EnterTime = oRd.Item(6).ToString
Else
oUserInfo.EnterTime = Now
End If
End While
pPage.Session("UserInfo") = oUserInfo
Return oUserInfo
Else
oUserInfo = Nothing
Return Nothing
End If
Catch ex As Exception
Return Nothing
Finally
isDBm.CloseConn()
isDBm = Nothing
End Try
End Function
...全文
相关推荐
JavaScript声明全局变量访问方法
JavaScript声明全局变量访问方法 JavaScript声明全局变量访问方法 JavaScript声明全局变量访问方法 JavaScript声明全局变量访问方法
C++ 中const总结
C++ 中const总结 const 限定符把一个对象转换成一个常量,如 const int bufSize=512; 申 明 bufSize 的时候,如果不将它初始化,那么编译器会报错:const object must be initialized if not extern。因为 bufSize 被 const 限定符限制,如果不在 申明 bufSize 的时候给它赋值,就不能再给它赋值(因为常量在定义之后就不能 被修改),它就没有任何意义了。 下面将详细的讨论一下 const 变量的作用域、const 指针、指向 const 对象的指 针、const 引用的相关用法。
全局变量的使用
extern全局变量的使用,简单的写了一下
C++语言const 关键字使用方法图文详解
在类中,如果你不希望某些数据被修改,可以使用const关键字加以限定。const 可以用来修饰成员变量、成员函数以及对象
C++语言中const默认是内部链接.zip
C++语言中const默认是内部链接


VB基础类
