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. General Programming
  3. C#
  4. DAL/BLL Best Practices

DAL/BLL Best Practices

Scheduled Pinned Locked Moved C#
databasebusinesshelptutorialquestion
4 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.
  • E Offline
    E Offline
    econner
    wrote on last edited by
    #1

    I am looking to create an Data Access Layer and Business Logic Layer for a new web site. I am looking for suggestions on the best practice on how to handle the database connection from the DAL. I have seen examples where every function in the DAL creates a connection, runs the query, and then closes the connection based on the connection string passed into the DAL. With connection pooling this doesnt seem to be a big issue. Is this the best method for a web application since it is stateless? Or, is it better for the BLL to create a connection and pass the connection into the DAL? How is the best way to get the connection string from the Web.config file to the DAL? Does the BLL pass the connection string into the DAL or is there a better way? I am looking at using ASP 2.0 but I didnt want to use the table adapter wizard. Any examples would be greatly appreciated.

    E 1 Reply Last reply
    0
    • E econner

      I am looking to create an Data Access Layer and Business Logic Layer for a new web site. I am looking for suggestions on the best practice on how to handle the database connection from the DAL. I have seen examples where every function in the DAL creates a connection, runs the query, and then closes the connection based on the connection string passed into the DAL. With connection pooling this doesnt seem to be a big issue. Is this the best method for a web application since it is stateless? Or, is it better for the BLL to create a connection and pass the connection into the DAL? How is the best way to get the connection string from the Web.config file to the DAL? Does the BLL pass the connection string into the DAL or is there a better way? I am looking at using ASP 2.0 but I didnt want to use the table adapter wizard. Any examples would be greatly appreciated.

      E Offline
      E Offline
      eggsovereasy
      wrote on last edited by
      #2

      All I can say is what I do... I keep ALL connection/database/sql out of the BLL. This way if my application moves to a different database all I have to do is rewrite the DAL and the rest of your application works fine. I also only use the presentation layer to do presentation; the BLL is what messes with the data.

      E 1 Reply Last reply
      0
      • E eggsovereasy

        All I can say is what I do... I keep ALL connection/database/sql out of the BLL. This way if my application moves to a different database all I have to do is rewrite the DAL and the rest of your application works fine. I also only use the presentation layer to do presentation; the BLL is what messes with the data.

        E Offline
        E Offline
        econner
        wrote on last edited by
        #3

        Do you have each function in the DAL also handle the connection? How do you recommend the best way to have the DAL get the connection string?

        E 1 Reply Last reply
        0
        • E econner

          Do you have each function in the DAL also handle the connection? How do you recommend the best way to have the DAL get the connection string?

          E Offline
          E Offline
          eggsovereasy
          wrote on last edited by
          #4

          Recently I've been using typed datasets, I think they open a connection each time. In my older projects I did open a connection for each request. However, my apps are internal workflow applications though, so they are not serving 100,000 hits /sec or anything :p I put the connection string in app.config.

          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