I faced some problem about sql connection issue. The problem is I have some code like this
function1()
{
using (sqlconnection sc = new sqlconnection())
{
foo();
}
}
foo is a function like below:
foo()
{
using (sqlconnection sc = new sqlconnection())
{
dosomething;
}
}
It seems that the sqlconnection in foo() cannot work. I'm wondering if it is a good idea to pass the sqlconnection into foo like foo(sc), or is it a good idea to take foo outside function1, or is there anyway to allow the sqlconnection inside foo works.
function1if all it's doing is calling another method?