Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005

    C#.NET and DB connections

    I am beginning to do websites based on C#.NET (experience in .NET for desktop apps and use php frequently for web stuff), however I can't find any real good documentation for handling DB connections for the web environment. Most just say to concatenate together a query string and send it to the server (bad idea) but this is okay because I have a pretty good handle of the .NET DB classes from my desktop app work. My question is can you have a persistent DB connection for your web application that spans pages/users, or do you need to initialize a new DB connection for each page load like with PHP? I have seen some people suggest you can do this, but never any demonstration of how you set it up.

  2. #2
    Join Date
    Feb 2007
    USA, UK, Singapore
    Well, I believe you should go through some documentation on ADO.NET as it should help you a long way in this. Additionally, I believe, you will need to open a connection each time you make db access and close it in final block.
    ██ Softsys Hosting ██ - 8 Years In Business - 24/7 In-House Support - Enterprise DDoS Protection Available!

    Enterprise Dedicated Servers - Fully Managed Windows & Linux Virtual Machines (US/UK/Singapore) - Failover Ready Cloud VM's

  3. #3
    Join Date
    Jun 2007
    London, United Kingdom
    Your best bet is to read though Zak Ruvalcaba's tutorial at SitePoint as that is where I learned most of my ASP.NET C#scripting Look though a couple chapters in to and there is DB connection stuff.

    Hope is helps.

  4. #4
    Join Date
    Apr 2004
    Houston, Tx
    Normally what you would do is setup a connection string in the web.config file and use that when you connect to the database. If you are using SQL Server I would highly recommend using LINQ2SQL or LINQ2Entities as it can save you LOTs of time. Feel free to PM me and I can help step you through.

Similar Threads

  1. mySQL Connections Too Many Connections
    By Matrix in forum Programming Discussion
    Replies: 13
    Last Post: 12-11-2008, 08:25 PM
  2. Too many connections from your ip address (reached max connections)
    By Gnomercy in forum Hosting Security and Technology
    Replies: 0
    Last Post: 11-09-2004, 01:28 AM
  3. Replies: 4
    Last Post: 07-21-2004, 10:11 AM
  4. FTP connections...
    By Bourd in forum Hosting Security and Technology
    Replies: 2
    Last Post: 12-12-2003, 12:05 PM
  5. Replies: 17
    Last Post: 07-09-2003, 02:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts