Project_Marmelade.Business.OptimizationBusiness.OptimPersist.GetProductInfo C# (CSharp) Method

GetProductInfo() public method

public GetProductInfo ( ) : List
return List
        public List<string> GetProductInfo()
        {
            List<string> dbProductNames = new List<string>();
            try
            {
                SqlCommand cmd = new SqlCommand("spGetProductNames", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.HasRows && rdr.Read())
                {
                    dbProductNames.Add((string)rdr["RecipeName"]);
                }
            }
            catch (SqlException e)
            {
                string s = e.Message;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }

            return dbProductNames;
        }
    }

Usage Example

        public List<string> GetProductNames()
        {
            OptimPersist db = new OptimPersist();
            List<string> prodList = db.GetProductInfo();

            return prodList;
        }