Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can not figure out the error in the code
Message
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01400621
Message ID:
01400629
Views:
34
Removing using from this code
/// <summary>
        /// Get Inventory Dictionary for passed category
        /// </summary>
        /// <param name="Category">Category</param>
        /// <returns></returns>
        public Dictionary<string, string> GetInventoryDictionaryByCategory(string Category)
        {
            Dictionary<string, string> list = new Dictionary<string, string>();

            ItemsTableAdapter ta = new ItemsTableAdapter();

            InventoryDS.ItemsDataTable dt = this.GetItemsByCategory(Category);
                
                    ta.Fill(dt);

                foreach (InventoryDS.ItemsRow dr in dt.Rows)
                {
                    list.Add(dr.itemdesc1, dr.pk.ToString());
                }                            

            return list;
        }        
seemed to bypass the errors, but what was wrong with my original way?

>Hi everybody,
>
>I could not figure out where is the error in the following code - need another set of eyes to help.
>
>
>/// <summary>
>        /// returns list of items by Category
>        /// </summary>
>        /// <param name="Category">Category</param>
>        /// <returns></returns>
>        public InventoryDS.ItemsDataTable GetItemsByCategory(string Category)
>        {
>            
>            ItemsTableAdapter ta = new ItemsTableAdapter();
>            return ta.GetItemsByCategory(Category);
>        }
>
>        /// <summary>
>        /// Get Inventory Dictionary for passed category
>        /// </summary>
>        /// <param name="Category">Category</param>
>        /// <returns></returns>
>        public Dictionary<string, string> GetInventoryDictionaryByCategory(string Category)
>        {
>            Dictionary<string, string> list = new Dictionary<string, string>();
>
>            using (ItemsTableAdapter ta = new ItemsTableAdapter())
>            {
>
>                InventoryDS.ItemsDataTable dt =  this.GetItemsByCategory(string Category);
>                
>                    ta.Fill(dt);
>
>                foreach (InventoryDS.ItemsRow dr in dt.Rows)
>                {
>                    list.Add(dr.itemdesc1, dr.pk.ToString());
>                }                
>            }
>
>            return list;
>        }
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform