Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Open Connection

Open Connection

Scheduled Pinned Locked Moved ASP.NET
designhelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Naunt
    wrote on last edited by
    #1

    Dear all, Please help. I created BasePage to open connection as following

    Public Class BasePage
    Inherits System.Web.UI.Page

    public 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.MasterPage

    Please help me how to make MasterPage know that connection? Thanks and Best Regards

    S 1 Reply Last reply
    0
    • N Naunt

      Dear all, Please help. I created BasePage to open connection as following

      Public Class BasePage
      Inherits System.Web.UI.Page

      public 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.MasterPage

      Please help me how to make MasterPage know that connection? Thanks and Best Regards

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups