Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close connection syntax

Status
Not open for further replies.

Isadore

Technical User
Feb 3, 2002
2,167
US
A tidbit - which of the two would be preferred:

myConnection.Open()
dgMyGrid.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
dgMyGrid.DataBind()

...or...

myConnection.Open()
dgMyGrid.DataSource = myCommand.ExecuteReader()
dgMyGrid.DataBind()
myConnection.Close()
 
You can explicitly call myConnection.Close() however it's not actually necessary because the garbage collection will do this for you.

 
I would advise closing the connection manually - it's a good habit.

James
 
Definitely the latter.
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top