Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can i use Include files for my connection in .net/ alternatives??

Status
Not open for further replies.

rahmanjan

Programmer
Apr 13, 2003
180
AU
Hi all,

In classical asp i could keep my connection details and objects in a seperate Include file and could keep it in the top of each asp file so i didn't need to open connection all over again. My questions are:

can i use Include files to keep my databse connections in asp.net? and Any better other alternatives?

regards,

rahman
 
You can create a class which manages your connection info, and then instantiate a copy of that class for use in your ASP code. That way all the messy details (connection string, etc) are hidden, and all your code sees is "MyDataClass.GetRecordset(.. ..)" making things much cleaner, and you can get some code reuse out of it too.

Chip H.
 
In addition to what Chip has said, its also much better to use the class alternative because you don't have a open connection for the full render of the page as you would in classic asp.

If you're just starting out in .NET, make sure you check into some ADO.NET resources. ADO.NET will blow your mind if you're used to simple recordsets to return data (way more options with .NET)

hth

D'Arcy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top