Solved

An explenation of a methode needed.

Posted on 2011-03-16
3
279 Views
Last Modified: 2013-12-17
Hi,

I have a question about this methode:

        public static DataSet GetHierarchy(string connectionString, int modelID)
        {
            string sql = "";
            DataSet ds = null;
            try
            {
                sql = "select * from hierarchy ";
                sql += "  where modelid=" + modelID.ToString();
                sql += "  order by parentnodeid,sortorder asc";
                ds = GetDataSet(connectionString, sql);
                SetHierarchyRelationships(ds);
            }
            catch (Exception) { throw; }
            return ds;
        }

1. Does anyone know what the sql-statement means?
2. What does this mean giving it the value null: DataSet ds = null;
3. What does += mean?

Peter
   
0
Comment
Question by:peterkiers
3 Comments
 
LVL 8

Accepted Solution

by:
crysallus earned 250 total points
Comment Utility
1. select all columns in the table hierarchy where the modelid column has the value in the modelID variable, and order the results in ascending order by the value in the parentnodeid column

2. It just initialises the ds to null so it doesn't refer to any instance of DataSet.

3. += for strings concatenates strings together, so each time, the string is being added to what sql already contains.
0
 
LVL 10

Assisted Solution

by:Mathiyazhagan
Mathiyazhagan earned 250 total points
Comment Utility
3. What does += mean?
   It is short-hand assignment operator. that, a value is added to left-handed variable and stored again in Left-handed variable.for example ,
  int  a =10;
  a+=5; //is equal to a= a+5, so a will 15
 
2.What does this mean giving it the value null: DataSet ds = null;
   yes, Dataset object is created with in try block. so , chances are there that it won't assigned with value
   if any error occurs before assigning value to it (ie, before   ds = GetDataSet(connectionString, sql)). but, we   need a defined value of ds before we are returning.so, it is initialized with Null value.

1. Does anyone know what the sql-statement means?
      I could not get your question.if you asking about variable "sql" means, it is string variable to
   store some string .
 
hope this helps.

0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
Thanks.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now