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. ASP.NET woes ...

ASP.NET woes ...

Scheduled Pinned Locked Moved ASP.NET
databasehelpcsharpasp-netdesign
4 Posts 4 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.
  • D Offline
    D Offline
    DFU23
    wrote on last edited by
    #1

    This is starting to confuse me and I think (?) this is a good place to post this problem. I am building a rather small and simple application so I have chosen to use an Access database for starting off. I like how simple things can be to make a web app with the Design View when making a ASP.NET application ... I think it handles most things pretty decently ... except I am stuck as to how to get the connection to the Access database in the Design view. I use the Server Explorer and connect to the Access DB with no problem. I drag the DB from the Server Explorer into my page and it creates a connection. Everything appears to be playing along nicely so far ... However, there is a problem. This application is going to reside on some other web server and I will need to do the old ASP trick of Server.MapPath() in the connection string. This is the beginning of my frustration. Since the connection string needs to be dynamically created (to get the absolute path to the DB) I cannot slap a static connection string as a key in the web.config file. Since the code behind likes to do its own thing in its "Web Form Designer generated code" segment in order to initialize connections and handle events I cannot go and try to change the connection string in there. I have tried to modify it and when it finds the change it simply takes out the connection string initialization completely. Any suggestions on a way to get around this?

    Wally Atkins
    Newport News, VA, USA

    M L 2 Replies Last reply
    0
    • D DFU23

      This is starting to confuse me and I think (?) this is a good place to post this problem. I am building a rather small and simple application so I have chosen to use an Access database for starting off. I like how simple things can be to make a web app with the Design View when making a ASP.NET application ... I think it handles most things pretty decently ... except I am stuck as to how to get the connection to the Access database in the Design view. I use the Server Explorer and connect to the Access DB with no problem. I drag the DB from the Server Explorer into my page and it creates a connection. Everything appears to be playing along nicely so far ... However, there is a problem. This application is going to reside on some other web server and I will need to do the old ASP trick of Server.MapPath() in the connection string. This is the beginning of my frustration. Since the connection string needs to be dynamically created (to get the absolute path to the DB) I cannot slap a static connection string as a key in the web.config file. Since the code behind likes to do its own thing in its "Web Form Designer generated code" segment in order to initialize connections and handle events I cannot go and try to change the connection string in there. I have tried to modify it and when it finds the change it simply takes out the connection string initialization completely. Any suggestions on a way to get around this?

      Wally Atkins
      Newport News, VA, USA

      M Offline
      M Offline
      Mark Sanders
      wrote on last edited by
      #2

      You could create a SitePage.cs base class which inherits from the ASP.NET web page base class. In the SitePage.cs you can define your connection which will be used for every page in the site. Then inherit from SitePage.cs in every page in the site instead of the standard ASP.NET web page base class. Mark Sanders sanderssolutions.com

      C 1 Reply Last reply
      0
      • M Mark Sanders

        You could create a SitePage.cs base class which inherits from the ASP.NET web page base class. In the SitePage.cs you can define your connection which will be used for every page in the site. Then inherit from SitePage.cs in every page in the site instead of the standard ASP.NET web page base class. Mark Sanders sanderssolutions.com

        C Offline
        C Offline
        ChrisWFL
        wrote on last edited by
        #3

        I'd do this with an Application variable. In the global.asax page, you can set the variable. In the Page_Load function you can then override the setting that's done in the Initialize_Component. You can also use the Advanced setting of the Configuration Properties to store this.

        1 Reply Last reply
        0
        • D DFU23

          This is starting to confuse me and I think (?) this is a good place to post this problem. I am building a rather small and simple application so I have chosen to use an Access database for starting off. I like how simple things can be to make a web app with the Design View when making a ASP.NET application ... I think it handles most things pretty decently ... except I am stuck as to how to get the connection to the Access database in the Design view. I use the Server Explorer and connect to the Access DB with no problem. I drag the DB from the Server Explorer into my page and it creates a connection. Everything appears to be playing along nicely so far ... However, there is a problem. This application is going to reside on some other web server and I will need to do the old ASP trick of Server.MapPath() in the connection string. This is the beginning of my frustration. Since the connection string needs to be dynamically created (to get the absolute path to the DB) I cannot slap a static connection string as a key in the web.config file. Since the code behind likes to do its own thing in its "Web Form Designer generated code" segment in order to initialize connections and handle events I cannot go and try to change the connection string in there. I have tried to modify it and when it finds the change it simply takes out the connection string initialization completely. Any suggestions on a way to get around this?

          Wally Atkins
          Newport News, VA, USA

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Add the connection string to the web config file, and make your connection string a Dynamic Property. I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

          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