abcd Posted June 25, 2003 Posted June 25, 2003 Any body please tell me how to declare the connection object public /global in asp.net and how to call the object in forms. Thanks in advance Quote
hrabia Posted June 25, 2003 Posted June 25, 2003 You have to declare your object in global.asax <object id="MyConnection" class="System.Data.SqlClient.SqlConnection" runat="server" scope="Application"></object> Than you can use it in following way: Dim moConn As System.Data.SqlClient.SqlConnection moConn = CType(Application.StaticObjects.Item("MyConnection"), System.Data.SqlClient.SqlConnection) BTW: It is VERY BAD idea having Connection object as global object. Because of connection pooling it is much better to create, use and destroy (close) connection to database as quickly as possible. Quote A man and a dog have an average of three legs. Beaware of Statistics.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.