Having multiple forms, you could make a singleton class that wraps around your connection. Then when calling your singleton instance, check if that connection is already open, and if it is, you don't open it again.
As you seem to be in luck today (I don't usually post code, but I am doing this kind of work as we speak, although I don't need to keep connections open across forms), I'll post you some stuff with basic comments:
class DatabaseServiceOracle {
private static DatabaseServiceOracle instance;
private static OracleConnection connection;
private DatabaseServiceOracle() {}
public static DatabaseServiceOracle getInstance() {
if(instance == null) {
instance = new DatabaseServiceOracle();
}
return instance;
}
public OracleConnection getConnection() {
if(connection == null) {
}
if(connection.State != ConnectionState.Open) {
connection.Open();
}
return connection;
}
}
Also, don't mind the formatting, although the code is C#, we have an internal convention that says we use the Java formatting conventions even when we do C#.
Also, the database system is Oracle and not SQL Server, but the point stands.
Furthermore, this is conceived for an MVC system, so in here would go most of the DB queries needed (it's just a basic template that we customize for our needs)