Lately I find myself writing data access layer select methods where the code all takes this general form:
public static DataTable GetSomeData( ... arguments)
One pattern I've enjoyed looks like this as far as client code goes:
DataTable data = null;
using (StoredProcedure proc = new StoredProcedure("MyProcName","[Connection]"))
{
proc.AddParameter("@LoginName", loginName);
data = proc.ExecuteDataTable();
}
I usually make connection optional, and I will code in a way to pull it from ConnectionStrings config section or treat it as the actual connection string. This lets me reuse the dal in one off scenario's and is in part a habbit from the COM+ days when I stored the connection string using the object construction property.
I like this because it's easy to read and hides all the ADO code from me.