CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.commerce_starter_kit Tags:
Item Type: NewsGroup Date Entered: 4/29/2004 4:11:47 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 6 Views: 17 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
7 Items, 1 Pages 1 |< << Go >> >|
ajs916
Asp.Net User
BUG: Reader.Close()4/29/2004 4:11:47 PM

0/0


Hello All,

Not Sure if this is a bug or not:

I was just wondering why IBS/Commerce Kit does not close a DataReader after binding. I was under the impression that the CommandBehavior.CloseConnection setting still requires that you close the reader (reader.close()) in order to close the connection. However, IBS binds to the datareader directly. Will this cause connection leaks, or does binding to a reader close it?

Am I missing something?? :)

Thanks,
Anthony
phache
Asp.Net User
Re: BUG: Reader.Close()9/16/2004 2:43:21 PM

0/0

I think that what you are describing is a problem. I keep running out of connections on my installation and this is probably because of the lack of close for the connections. I've added code pretty much everywhere to close the dataReaders after the DataBind() method (usually in the Page_Load Subs), for example like this (in _AlsoBought.ascx):

alsoBoughtList.DataSource = productCatalogue.GetProductsAlsoPurchased(ProductID)
alsoBoughtList.DataBind()
alsoBoughtList.DataSource.Close()


But this does not get rid of the problem for me. Any ideas on what could be missing or what I am doing wrong? I am still running out of connections all the time, and there are 100 so that should be plenty.

Thanks!
ajs916
Asp.Net User
Re: BUG: Reader.Close()9/16/2004 4:08:48 PM

0/0

Phache,

Yes more of a problem then a bug. I looked into this a bit more, and Binding to a DataReader *does* seem to close it, in your case try this:

Dim rdr As SqlDataReader = productCatalogue.GetProductsAlsoPurchased(ProductID)
alsoBoughtList.DataSource = rdr
alsoBoughtList.DataBind()

Response.Write(rdr.IsClosed) ' Should be true.

It seems that binding a Reader does in fact close it. Odd, as the MSDN states otherwise.

Anyway, to answer your question: A) Are you using CommandBehavior.CloseConnection in your ExecuteReader method? B) What type of SQL Security are you using, Intergrated (Windows) or SQL Native (SQL UID/PWD). Remember that the connection string must be identical for connection pooling to work, even a space in the string would cause another pool to be created. I would say try using SQL Security and puting the connection string in the web.config file. Can you post your connection string and Data Access Layer so I can take a look at it?
phache
Asp.Net User
Re: BUG: Reader.Close()9/16/2004 5:55:34 PM

0/0

Hi ajs916 and thanks for your reply. You are right, when I check IsClosed in the way that you described, I get a true and so I should have realeased the connection back into the pool (I have a pool of 100 available connections). I am using CommandBehavior.CloseConnection in the ExecuteReader methods like you described (because that's how it was coded in the starter kit), for example:

Public Function GetProductCategories(ByVal LanguageCode as String) As SqlDataReader

' Create Instance of Connection and Command Object
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As SqlCommand = New SqlCommand("CONC_ProductCategoryList", myConnection)

' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure

' Add Parameters to SPROC
Dim parameterLanguageCode As SqlParameter = New SqlParameter("@LanguageCode", SqlDbType.Char, 2)
parameterLanguageCode.Value = LanguageCode
myCommand.Parameters.Add(parameterLanguageCode)

' Execute the command
myConnection.Open()
Dim result As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

' Return the datareader result
Return result

End Function

Also, my connection string is like so (in the web.config file) and is used everywhere with SQL Native security:

<appSettings>
<add key="ConnectionString" value="server=localhost;database=Commerce;User ID=(user);Password=(password);Connection Lifetime=300;" />
</appSettings>

I have tried to keep track of connections by counting them in SQL Server like this:

select count(*) from sysprocesses
WHERE LOGINAME='(loginname)'

and sure enough, the site gives up after I reach 100, which is really quick. Any insight that you could have is really appreciated. I have gone through the whole code and I don't believe that there are any places where I forget to close or use CommandBehavior.CloseConnection.
Maybe you were experiencing the same problem?

Thanks!
phache
Asp.Net User
Re: BUG: Reader.Close()9/18/2004 12:26:19 AM

0/0

I think that what may be going on here is explained here. I will try it on my code.

http://blogs.msdn.com/angelsb/archive/2004/08/25/220333.aspx

Phil
ajs916
Asp.Net User
Re: BUG: Reader.Close()9/18/2004 1:55:45 PM

0/0

I looked at your code. It seems everything is in order, here are a few recommendations

1) After looking into this more, I still think you should close your readers explictly. Even though the IsClosed method is true, I think this is misleading. This could be that the reader has finished reading records and closed itself. Try this:

' Fetch Reader
Dim rdr As SqlDataReader = productCatalogue.GetProductsAlsoPurchased(ProductID)

' Bind to DataGrid
alsoBoughtList.DataSource = rdr
alsoBoughtList.DataBind()

' Close Reader
rdr.Close()

2) Put a try and catch block and make sure to close your connections when execptions occur (check the cn.State Property).

3) Step through your code and monitor the connections in Sql Profiler during the connection opening and the connections and readers closing.

4) What version of SQL Server are you using? Is this the only application using this db? What is the licensing? Per CPU or Connection?



ajs916
Asp.Net User
Re: BUG: Reader.Close()9/18/2004 2:03:58 PM

0/0

Try this article too :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconconnectionpoolingforsqlservernetdataprovider.asp

Connection LifeTime might not be required in your Connection string. Also take a look at the performance monitors at the end of the article.
7 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Programming ASP.NET: Building Web Applications and Services Using C and VB.NET. Authors: Jesse Liberty, Dan Hurwitz, Pages: 988, Published: 2003
Managing the Testing Process: Practical Tools and Techniques for Managing Hardware and Software Testing Authors: Rex Black, Pages: 528, Published: 2002
The New Media Reader: edited by Noah Wardrip-Fruin & Nick Montfort Authors: Noah Wardrip-Fruin, Nick Montfort, Pages: 823, Published: 2003

Web:
MySQL Bugs: #20581: Null Reference Exception when closing reader ... Bug #20581, Null Reference Exception when closing reader after stored procedure. Submitted: 20 Jun 2006 20:01, Modified: 24 Aug 2006 11:59 ...
MySQL Bugs: #11941: CommandBehavior.SingleRow causes reader.Close ... Bug #11941, CommandBehavior.SingleRow causes reader.Close() to throw error. Submitted: 14 Jul 2005 16:47, Modified: 11 Oct 2005 10:46 ...
Bug ID: 6539065 XMLStreamReader close the underlaying stream END_DOCUMENT; nodeType = reader.next()) { //BUG: When nodeType == END_DOCUMENT - > Reader close stream System.out.println(nodeType); } reader.close(); ...
[Bug 293359] Re: When ejecting a CD/DVD media the cd reader close ... Nov 3, 2008 ... [Bug 293359] Re: When ejecting a CD/DVD media the cd reader close itself immediatly !!! Chris Coulson chrisccoulson at googlemail.com ...
Bug ID: 4893524 Swing drop targets should call close() on ... It should be closed as soon as possible to release some native resources. Missing Reader.close() led to the manifestation of the bug 4888520. ...
[Mono-bugs] [Bug 334752] New: XmlReader.Close() misbehaves when ... Previous message: [Mono-bugs] [Bug 322809] Bugs in menu control ... ReadToDescendant("item"); reader.Close(); } } } ################## The correct output ...
Re: Bug: Input Stream not closed in unparsed-text(: msg#00153 Re: Bug: Input Stream not closed in unparsed-text(): msg#00153 ... (Shouldn't one technically close the Reader rather than the underlying InputStream? ...
Mailing list archives Subject, DO NOT REPLY [Bug 3905] New: - request.getIntputStream()/Reader.close() problem. Date, Mon, 01 Oct 2001 17:32:56 GMT. DO NOT REPLY TO THIS EMAIL, ...
#474251 - RFA: yasr -- General-purpose console screen reader ... Message #10 received at 474251-close@bugs.debian.org (full text, mbox): ... Changed Bug title to `RFA: yasr -- General-purpose console screen reader' from ...
Feedback: *** DELETE, NOT A SQL BUG *** MSFT - EDW: PBM ... NOT A SQL BUG ... Please close. This can be reproed by doing only $reader thing, and is simply a side effect of Garbage Collection. ---------------------- ...

Videos:
HBO Hacking Democracy The Pima County Way RTA Card Reader In the RTA election of May 16, 2006 more than 70 optical scanners failed on Election Day at various precincts. Election day I was out ...
Human Trafficking-Industry UNODC Regional Office for Brazil and South Cone has just launched a new public service announcement (PSA) on human trafficking to raise awareness ...
Jay-Z And Linkin Park - Points Of Authority/99 Problem - WITH ... Get the ringtone: http://www.ringtonegal.com/JayZ-And-Linkin-Park/Points-Of-Authority99-Problem/ Lyrics: Artist: Linkin Park with JAY-Z ...
Savanna Cat Savannah cats and kittens from Avalon Savannahs cattery may appear at first to have come straight out of the wild African savannah grasslands but ...
THIS VIDEO IS BETTER THAN ... Of Mice and Men essay writing is usually assigned to students taking Literature class. Of Mice and Men is a novel by J. Steinbeck (published in ...
DWN BYYYYY DAA RIVAAA Of Mice and Men essay writing is usually assigned to students taking Literature class. Of Mice and Men is a novel by J. Steinbeck (published in ...
John F. Kennedy 'President and the Press' Speech April 4, 1961 Waldorf-Astoria Hotel, New York NY Speaking before the American Newspaper Publisher's Association. Full Transcript: Mr. Chairman, ladies and ...
p6apclps #12 Perl 6 Apocalypse http://www.perlfoundation.org/perl6 - - of the standard input filehandle is $*STDIN, but a package may just refer to $STDIN, and it will default ...
Illuminati: The Hidden Agenda for World Government Illuminati: The Hidden Agenda for World Government An interview with Norman Dodd




Search This Site:










course management software

button for submit is not working

image list question

password recovery - convert to template not working?

customize portal ...

themes includes all css files

menu control, statichoverstyle issue with image background

how to get asp.net templates in my vs2005

is dotnet capable of...

netmedia presents: uniview 2.03

getting windows username while using forms authentication

a few pointers please!

error in user aspnet_regsql.exe

dnn 3.0.7 - modulebase.getediturl() behavior

dnn theme music.

asp issue: not displaying the same on ie and firefox

problem uploading containers

encryption settings and key

help: i want the ability to have 2 menu areas, possible?

export template problem

how do i do this on a web server?

developing portal ui architectures with web parts

starter kit on vwdhosting.net, default admin password

uploading portal to server

include assets in library

how do we generate the xml documentation from asp.net web project.

access denied to 'c:\inetpub\wwwroot\web.config'

please help me

dynamic html & asp.net 2.0

login status control not logging out

 
All Times Are GMT