Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 24th, 2007, 08:14 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Bangalore, Karnataka, India.
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default close sql connection

hello to all
i am finding my self in confusing problem.

everyay log file of my application increase by 10 GB.
every time i found more than 100 connections open in SDQL Server 2005 under my database.

i an using SQLHELPER Class by microsoft.i ma not putting my code in try-catch block. example

of one of my frequently used function is as follows:

        protected Int64 GetMemberID()
        {
            String SqlSelect = "SELECT * FROM MemberMaster WHERE MemberUserName= '" +

Session["UserName"].ToString() + "'";
            SqlDataReader dr1 =

SqlHelper.ExecuteReader(ConfigurationManager.Conne ctionStrings["CowcallConnectionString2"].T

oString(), CommandType.Text, SqlSelect);
            while (dr1.Read())
            {
                CurrentMemberID = Int64.Parse(dr1["MemberID"].ToString().Trim());
            }
            return CurrentMemberID;
        }

well i doubt i am opening connection and do not closing it. moreover i do not know how to close connection in above code when i am using sql helper class.
please give me yours suggestion regarding my code even if it is not solving above two problems.

thanks......
__________________
thanks......
  #2 (permalink)  
Old September 24th, 2007, 09:08 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. I don't know how the helper class work, but when you use a reader you have a connection object and a command object open.. so after you use the reader you have to dispose them somewhere.. so maybe you have a method to do that???

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
  #3 (permalink)  
Old September 26th, 2007, 01:13 AM
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Supporting Gonzalo, there is a property with datareader as "CommandBehavior.CloseConnection" which automatically closes the connection once data is fetched, so study that...

Regards
Mike
  #4 (permalink)  
Old September 27th, 2007, 10:32 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Bangalore, Karnataka, India.
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

thanks i try this.
i want to know if i am not to use sqlhelper class. what's other way to access connection string and use SQL query. is i am to write again and again

thanks......
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When should you close the database connection? Stickannn Pro PHP 0 September 13th, 2007 04:25 AM
ASP / ADODB - How to close connection? hamproof Classic ASP Databases 4 August 24th, 2007 01:43 PM
sqldatareader close connection mdonner BOOK: Beginning ASP.NET 1.0 2 July 5th, 2007 04:50 AM
Command Object -- How to close db connection? wolfpack391 Classic ASP Databases 4 July 31st, 2004 05:28 AM
Open/Close SQL Connection within every method? flyin ADO.NET 8 May 18th, 2004 07:19 AM



All times are GMT -4. The time now is 08:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.