示例#1
0
        public override decimal GetTaxRate(string zip)
        {
            decimal dOut = 0;

            //load the default db from the base class
            Microsoft.Practices.EnterpriseLibrary.Data.Database db = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase();
            //specify the SP
            string cmd = "CSK_Tax_GetTaxRate";

            using (DbCommand dbCommand = db.GetStoredProcCommand(cmd)) {
                db.AddInParameter(dbCommand, "@zip", DbType.String, zip);
                //return a reader using the Ent Blocks
                using (IDataReader rdr = db.ExecuteReader(dbCommand)) {
                    if (rdr.Read())
                    {
                        dOut = (decimal)rdr["rate"];
                    }
                }
                //load routine closes the reader if flag is set to true;
                return(dOut);
            }
        }