SQLServerCentral.com / Discuss Content Posted by Jon Winer / Article Discussions / Article Discussions by Author / An introduction to using the ADO.NET - SqlCommand Object / Latest PostsInstantForum.NET v2.9.0SQLServerCentral.comhttp://www.sqlservercentral.com/Forums/notifications@sqlservercentral.comSun, 02 Aug 2015 14:30:18 GMT20RE: An introduction to using the ADO.NET - SqlCommand Objecthttp://www.sqlservercentral.com/Forums/Topic1806-30-1.aspx<P>I know this is just an example that you presented in the article. So I have a recommedation ( learnt over time).</P><P>When you are working with connections to the database using the command object, I would sincerely recommend the following technique . The following practice will keep the connection pool in better control:</P><P>Instead of myCommand.Open(); or myCommand.Close(); directly</P><P>Use this while opening connections:</P><P> if( myCommand.Connection.State == ConnectionState.Closed) myCommand.Open();</P><P> </P><P>Use this while closing connections:</P><P> if( myCommand.Connection.State == ConnectionState.Open) myCommand.Close();</P>Fri, 06 Aug 2004 10:13:00 GMTLooney TunezezRE: An introduction to using the ADO.NET - SqlCommand Objecthttp://www.sqlservercentral.com/Forums/Topic1806-30-1.aspxYou might want to add that the syntax:cmdMyCommand.Parameters("@LastName") = strLastNamethat works just fine under ADOdoesn't seem to work under ADO.Net.Sprocs don't seem to know anything about their parameters until execution. I guess it makes sense when one considers the basic idea behind ADO.Net is to do away with stateful database interactions. This change was the cause of some consternation here, as disappearance of the the old syntax does not seem to be documented anywhere. Brian BegyChicago Data SolutionsFri, 26 Apr 2002 15:47:00 GMTbfbegyAn introduction to using the ADO.NET - SqlCommand Objecthttp://www.sqlservercentral.com/Forums/Topic1806-30-1.aspxComments posted to this topic are about the content posted at <A HREF=http://www.sqlservercentral.com/columnists/jwiner/anintroductiontousingtheadonetsqlcommandobject.asp>http://www.sqlservercentral.com/columnists/jwiner/anintroductiontousingtheadonetsqlcommandobject.asp</A>Fri, 30 Nov 2001 00:00:00 GMTjwiner