In the class you where you want to build your queries, declare each method to accept a SqlConnection
parameter.
// query method
public void SomeQuery(SqlConnection connection)
{
...
}
// use it
using(SqlConnection aConnection=new SqlConnection('ConnectionString')
{
aConnection.Open();
otherClass.SomeQuery(aConnection);
}
Passing a parameter will create a copy of the reference to the SqlConnection
object which will be in scope within the called method. Make sure you don't leak it outside the method though.