Hey, I currently have this method in my code:
public static DataSet PrepareDataSet(some params)
{
SqlConnection sqlConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter adapter = new SqlDataAdapter(Utils.EscapeProcedureName(...), sqlConnection);
adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
//do some stuff with the adapter using the params
sqlConnection.Open();
DataSet dataSet= new DataSet();
adapter.Fill(dataSet);
sqlConnection.Close();
return dataSet;
}
This code is called from an aspx.cs page. Is it a good approach to have the SQL connection stuff and the adapter inside the method? If not, how can that be refactored? Somehow I think this is not good for testing for example ...
Thanks for ur ideas :)