PDA

View Full Version : ASP.net > Open Close db Connection: Best Practice



irealtysolution
08 May 2012, 09:04 AM
Hi,

I am a Classic ASP developer and now learning ASP.net.
In Classic ASP, I developed a few functions that Connects, Executes Queries & Disconnect databases like for example:



//To Connection to db
set objConn = connectDB()




//Exceute Select Query
set rRecordSet = executeQuery("sql query here", objConn)




//Disconnect database
disConnect(objConn)


Is there any Expert .Net developer who can guide me on how to create similar functions in .Net so that I do not have to write same db connection code in each page of application.


Thanks!

Lechlak
08 May 2012, 10:46 PM
Why not write this as an external file like db.aspx and then include it on the page?