|
October 14, 2002 The SqlConnection Class Tips: October 2002
Yehuda Shiran, Ph.D.
|
|
Every time you want to retrieve records from an SQL database, you need to open a connection to it, read the records, and then close the connection. You accomplish this sequence with the SqlConnection object. You need to create an instance of SqlConnection, call its Open() method, read the records with an SqlCommand instance object, and then close the connection by either passing the constant CommandBehavior.CloseConnection to the SqlCommand instance object, or by calling the SqlConnection's Close() method.
The constructor of the
Here is the constructor line repeated by each and every method of the five JScript .NET modules:
Here is how we open the connection, retrieve records from the database, and close the connection:
And here is how we open the connection, retrieve some parameters (as opposed to records), and close the connection:
People who read this tip also read these tips: Look for similar tips by subject: |