Shouldn't I be able to add a sub to the "Global.asax.vb" file and use it in a aspx.vb file? I don't have to inherit the global file in the aspx.vb file do I?
KizMar
------------
KizMar
------------
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Request is not available in this context
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Request is not available in this context
Source Error:
Line 9: Dim dsn As String
Line 10: Dim prodIP = ConfigurationSettings.AppSettings("ProdIP")
Line 11: Dim server = Request.ServerVariables("SERVER_NAME")
Line 12:
Line 13: If server <> prodIP Then
Source File: d:\inetpub\[URL unfurl="true"]wwwroot\maximizetech\time\PubClasses.vb[/URL] Line: 11
Imports System.Web
Imports System.Web.SessionState
Imports System.Data.SqlClient
Public Class PubClasses
Inherits System.Web.HttpApplication
Public Function OpenConn2DB()
Dim dsn As String
Dim prodIP = ConfigurationSettings.AppSettings("ProdIP")
[COLOR=red]Dim server = Request.ServerVariables("SERVER_NAME")[/color]
If server <> prodIP Then
dsn = ConfigurationSettings.AppSettings("DB_Test")
Else
dsn = ConfigurationSettings.AppSettings("DB_Live")
End If
Dim myConn = New SqlConnection(dsn)
myConn.Open()
End Function
End Class
Dim server = HttpContext.Current.Server.MachineName
Try
' Code Here
Catch ex As Exception
' You can look at the ex object if an error occurs
Finally
' If you need to do anything regardless of whether an error occurred
End Try
Dim sqlQuery = "query here"
Dim myClasses As New PubClasses
myClasses.SetUpConnection()
Dim myCommand As New SqlCommand(sqlQuery, [COLOR=red]myConn[/color])
Dim myrdr As SqlDataReader = myCommand.ExecuteReader