sansat6699 Posted June 24, 2008 Share Posted June 24, 2008 i have my connection string placed in appsetting tag in web.config file and i am accesing it in class as sqlconnection con1=new sqlconnection (configurationsetting.appsettings["myconnection"]);now problem is that is it ok that if i created instance of class on another pagae like classreport abc= new Classreport ;then i am accessing that instance with connection created in itlike abc.con1.open();it's a multiuser application so it is okey to open connection from class in page , or recomend me better approch connection with sqlserver Link to comment Share on other sites More sharing options...
jesh Posted June 24, 2008 Share Posted June 24, 2008 My understanding is that it doesn't matter where you have your SqlConnection object - you can put it in a stand-alone data connection class, you can have it in your data object classes, or you can do it right on the page. What matters, however, is that you use the same connection string to open each of your connections (so .NET can use Connection Pooling) and that you close those connections as soon as you are done using them (so that you don't tie those connections up when other processes attempt to use them). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.