DataSet DsResults = oUserBizObject.ValidateUserID("JohnSmith","Washington");2) Your business object would be something like the following, with a call to your data access layer
public class UserBizObject : BaseBizObject .. public DataSet ValidateUserID(string cUserID, string cPassword) { // this is a simple example, where the biz object simply passes the 2 parameters on to the data access layer. However, // there may be special rules about setting these parameters before calling the data access piece. return oUserDataAccessObject.ValidateUserID(cUserID, cPassword); }3) You define the name of the stored procedure and parameter objects in your data access object for the User Manager (below).
public class UserDataAccessObject : BaseDataAccessObject .. public DataSet ValidateUserID(string cUserID, string cPassword) { ArrayList aSqlParms = new ArrayList(); aSqlParms.Add(new SqlParameter("@cUserID",cUserID)); aSqlParms.Add(new SqlParameter("@cPassword",cUserPassword)); DataSet DsReturn = this.GetStoredProcResults("spValidateUserID",aSqlParms); return DsReturn; }4) Last, but very important...the base class BaseDataAccessObject contains all the method calls to the back-end database. I'm posting one function, GetStoredProcResults, which was referenced above. It reads the arraylist of parameter objects, sets the data adapter accordingly, calls the stored proc, and returns the results.
public class BaseDataAccessObject .. protected DataSet GetStoredProcResults(string cProcName, ArrayList aParameters) { SqlConnection oSqlConn; oSqlConn = this.GetConnection(); DataSet DsReturn = new DataSet(); SqlDataAdapter oSqlAdapter = new SqlDataAdapter(cProcName, oSqlConn); oSqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; foreach(SqlParameter oParms in aParameters) oSqlAdapter.SelectCommand.Parameters.Add(oParms); oSqlAdapter.Fill( DsReturn,"MyData"); oSqlConn.Close(); return DsReturn; }Note that your base Data Access class would need additional methods for other types of back-end processes (e.g. ExecuteNonQuery).