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.
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!
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.