Open Connection
-
Dear all, Please help. I created BasePage to open connection as following
Public Class BasePage
Inherits System.Web.UI.Pagepublic Dim acon As New SqlConnection Protected Overridable Sub Page\_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init acon= new SqlConnection(ConfigurationManager.ConnectionStrings("DOCDBDWHConnectionString").ConnectionString) acon.open() End Sub
Inherits to normal page is works. But don't know how do use that connection in MasterPage
Partial Class Site
Inherits System.web.UI.MasterPagePlease help me how to make MasterPage know that connection? Thanks and Best Regards
-
Dear all, Please help. I created BasePage to open connection as following
Public Class BasePage
Inherits System.Web.UI.Pagepublic Dim acon As New SqlConnection Protected Overridable Sub Page\_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init acon= new SqlConnection(ConfigurationManager.ConnectionStrings("DOCDBDWHConnectionString").ConnectionString) acon.open() End Sub
Inherits to normal page is works. But don't know how do use that connection in MasterPage
Partial Class Site
Inherits System.web.UI.MasterPagePlease help me how to make MasterPage know that connection? Thanks and Best Regards
naunt wrote:
lease help me how to make MasterPage know that connection?
Connection is not a kind of thing to open in a base page and leave it! You need to read on SQLConnections [^]before coding further. Whenever needed, wherever needed, open the connection and have a finalize block to make sure you close the connection as soon the work is done.