Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

An introduction to using the ADO.NET - SqlCommand Object Expand / Collapse
Author
Message
Posted Friday, November 30, 2001 12:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, December 07, 2010 6:58 AM
Points: 115, Visits: 17
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/jwiner/anintroductiontousingtheadonetsqlcommandobject.asp


Post #1806
Posted Friday, April 26, 2002 3:47 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, June 28, 2007 10:55 AM
Points: 1, Visits: 1
You might want to add that the syntax:

cmdMyCommand.Parameters("@LastName") = strLastName
that works just fine under ADO
doesn'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 Begy
Chicago Data Solutions



Brian Begy
Chicago Data Solutions
Post #24584
Posted Friday, August 06, 2004 10:13 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 08, 2005 11:22 AM
Points: 2, Visits: 1

I know this is just an example that you presented in the article. So I have a recommedation ( learnt over time).

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:

Instead of myCommand.Open(); or myCommand.Close(); directly

Use this while opening connections:

    if( myCommand.Connection.State == ConnectionState.Closed)
            myCommand.Open();

 

Use this while closing connections:

    if( myCommand.Connection.State == ConnectionState.Open)
            myCommand.Close();

Post #130626
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse