Using SqlConnnection in Desktop Application

mutlyp

Member
Joined
Oct 11, 2012
Messages
8
Programming Experience
10+
on a page when you want to do anything with SQL you first have to put
con = New SqlConnection(connectionString)
and then when you are done you have to close the connection
con.Close()
My question is if on the same page you have other SQL quieries you need to do. Can you just declare con = New SqlConnection(connectionString) at the top of the page and then not have to use con = New SqlConnection(connectionString) through out the rest of the page as long as you close then open the con?
Or do you have to use con = New SqlConnection(connectionString) everytime you want to do a SQL query on the page?

Hope this makes since.
Thanks
 
Back
Top