troubleshooting Question

C# Microsoft Enterprise Library 4.1 - return DataTable

Avatar of jamesdean666
jamesdean666 asked on
C#
5 Comments1 Solution745 ViewsLast Modified:
I am using the Code below and am new to the Enterprise Library.. I can't figure out how to return the datatable with my 'return' statement?  I am used to using the .Add or .Fill technique in my code.

Thanks..
public static BCT.RapidChange.WebApp.Data.PolicyMortgageeDs.MORTGEEDataTable GetMortgeeByPolicy2(String policyNumber, Int32 portfolioSet)
        {
            BCT.RapidChange.WebApp.Data.PolicyMortgageeDs.MORTGEEDataTable dt = new BCT.RapidChange.WebApp.Data.PolicyMortgageeDs.MORTGEEDataTable();
 
            try
            {
                Database db = DatabaseFactory.CreateDatabase("HMWCPYConnectionString");
                StringBuilder sbQry = new StringBuilder();
 
                sbQry.Append("SELECT REGISTER.POLICY_NUMBER, MORTGEE.DATE_TIME, MORTGEE.MORTGEE_NUMBER, MORTGEE.MORTGEE_NAME, MORTGEE.MORTGEE_ADDR_1, ");
                sbQry.Append("MORTGEE.MORTGEE_ADDR_2, MORTGEE.MORTGEE_ADDR_3, MORTGEE.MORTGEE_ZIP_CODE, MORTGEE.MORTGEE_TYPE, MORTGEE.MORTGEE_CITY, MORTGEE.MORTGEE_STATE, ");
                sbQry.Append("MORTGEE.COUNTRY, MORTGEE.ADDRESS_TYPE, MORTGEE.TAX_ID,E.DESCRIPTION AS LOAN_NUMBER, E.SEQUENCE_NUMBER ");
                sbQry.Append("FROM MORTGEE , REGISTER , ENDORSEMENT E ");
                sbQry.Append("WHERE MORTGEE.MORTGEE_NUMBER = E.NAME_AND_ADDRESS ");
                sbQry.Append("AND REGISTER.POLICY_NUMBER =  E.POLICY_NUMBER ");
                sbQry.Append("AND REGISTER.POLICY_DATE_TIME =  E.POLICY_DATE_TIME ");
                sbQry.Append("AND REGISTER.STATUS_3='A' ");
                sbQry.Append("AND REGISTER.PORTFOLIO_SET = @PORTFOLIO_SET ");
                sbQry.Append("AND REGISTER.POLICY_NUMBER=@POLICY_NUMBER ");
                sbQry.Append("AND E.TERMINATION_DATE IS NULL ");
                sbQry.Append("AND E.IDENTIFIER IN ('01w', '03Y', '03i') ORDER BY E.SEQUENCE_NUMBER ");
 
                string sql = sbQry.ToString();
                DbCommand cmd = db.GetSqlStringCommand(sql);
 
                db.AddInParameter(cmd, "@POLICY_NUMBER", DbType.String, policyNumber);
                db.AddInParameter(cmd, "@PORTFOLIO_SET", DbType.Int32, portfolioSet);
 
                using (IDataReader polMortgeeReader = db.ExecuteReader(cmd))
                {
                    while (polMortgeeReader.Read())
                    {
                        PolicyMortgagee policyMort = new PolicyMortgagee();
                        policyMort.Load(polMortgeeReader);
                        //mortByPolList.Add(policyMort);
                        //dt.fil                                             
                    }
                    return dt;
                }
 
 
                return dt;
 
            }
            catch (Exception ex)
            {
                log.ErrorException(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                throw;
            }
        }
ASKER CERTIFIED SOLUTION
avarmaavarma

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros