Try using Static class and variables for this.
public static class DataAccessClass
{
static SqlConnection objConn = new SqlConnection();
public static SqlConnection MyConnection
{
get { return objConn; }
}
public static void OpenConnection()
{
string ConnectionSring = "MYCONNECTIONSTRING";
objConn.ConnectionString = ConnectionSring;
objConn.Open();
}
public static void CloseConnection()
{
objConn.Close();
}
}
This is very basic structure i am describing here.
I am not doing your homework so you have to add your code and exception handling by yourself.
Once you initiate the connection
DataAccessClass.OpenConnection();
Your connection is open for throughout the application and you don't have to open it again.
I suggest that YOU MUST NEVER IMPLEMENT THIS as it is a bad practice to leave Connection open.
Better way is to open connection execute your database operations and close it immediately.