New Message on dotNET User Group Hyd

Need Help urgently transaction problem

Reply
  Recommend Message 2 in Discussion
From: Sreeram

Hi Lokanath..
 
      Your guess that u r doing wrong is correct. You cannot keep the connection open throughout your application. You should try to close the connection as and when the requirement is over. You may have the doubt that if u keep closing the connection and reopening it number of times in the same form, will it not effect the performance as opening of new connection is required at each point of time.  The answer to this doubt is SQL Connection pooling will take care of your new connections. SQL server maintains connection pool from which it allots a connection whenever a request for new connection comes.
 
Coming to your problem, there are two ways to solve your problem.
 
1. The first one is you should have one module or class file where in you define different functions like Exec_Dataset, Exec_NonQuery, Exec_DataReader having return types as Dataset, nothing and DataReader and so on. If you want to open a datareader from your form, you need to just declare a datareader object and call the exec_DataReader function by passing the query string, which returns a Datareader object. In the function, you need to declare a connection, command objects and return the datareader. You will close the connection in the function itself.
 
2. You cannot have a global connection and control your transactions efficiently. YOu can have either form level or module level local connections through which you can efficienctly manage the transactions.
 
Hope everything is clear.
 
Regards
 
Sreeram

View other groups in this category.

Click here!
Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to