Solved

An explenation of a methode needed.

Posted on 2011-03-16
3
281 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
ID: 35146735
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
ID: 35146743
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
ID: 35146789
Thanks.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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