M
Matt
Hi all,
I'm currently writing a windows-forms based application in C# using
visual studio express. It interfaces with an Access Database backend
and at the moment, I have a seperate connection for every function
(such as a button click) that I use. This means that at the moment, my
program is doing the following in a number of places:
1) On Form_Load, read the list of users from the database then close
the data connection
2) When the button is pushed to get the details of a specific user,
open the data connection (respecifying the variables including the
connection string), select the data and then close the connection
I'm from a PHP development background, so what I would like to do is
this:
1) Declare an application wide database connection object.
2) when any form is loaded, open the database object, do what you have
to do and close the connection.
3) if a button is clicked, open the same database object, do what you
need to do and close the object.
In the past (using PHP), I've declared the variable/object at the start
of the session and then just opened and closed it as needed. How do I
do this in C#?
Cheers,
Matt
I'm currently writing a windows-forms based application in C# using
visual studio express. It interfaces with an Access Database backend
and at the moment, I have a seperate connection for every function
(such as a button click) that I use. This means that at the moment, my
program is doing the following in a number of places:
1) On Form_Load, read the list of users from the database then close
the data connection
2) When the button is pushed to get the details of a specific user,
open the data connection (respecifying the variables including the
connection string), select the data and then close the connection
I'm from a PHP development background, so what I would like to do is
this:
1) Declare an application wide database connection object.
2) when any form is loaded, open the database object, do what you have
to do and close the connection.
3) if a button is clicked, open the same database object, do what you
need to do and close the object.
In the past (using PHP), I've declared the variable/object at the start
of the session and then just opened and closed it as needed. How do I
do this in C#?
Cheers,
Matt