?
Solved

An explenation of a methode needed.

Posted on 2011-03-16
3
Medium Priority
?
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
crysallus earned 1000 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 1000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

649 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