title: Pupulate Tree view in C# via getting the dependencies of a Stored Procedure
body: <p>I am working on getting the dependencies of a Stored Procedure
  via using C# with Sybase DB
  the task is not related only for getting the dependencies for parent one, the task is related to get all Levels of childs ..
  The gate for executing this task via using:</p>
  
  <pre><code>sp_depends
  </code></pre>
  
  <p>The result will be on Treeview</p>
  
  <p>I complished only the first Level via the following Code</p>
  
  <pre><code>    private void CreateTree()
      {
  
          TreeNode ns = new TreeNode(txtProcName.Text.Trim());
          ArrayList array = GetDepends(txtProcName.Text.Trim());
  
          for (int i = 0; i &lt; array.Count; i++)
          {
              ns.Nodes.Add(array[i].ToString(), array[i].ToString());
              ArrayList array2 = GetDepends(txtProcName.Text.Trim());
          }
  
          treeView1.Nodes.Add(ns);
      }
  
      private ArrayList GetDepends(string sProcName)
      {
          ds.Clear();
          ArrayList  list = new ArrayList();
          ConnectionString = "Provider=SQLOLEDB;Data Source='" + txtServerName.Text.Trim() + "';Port=" + txtPort.Text.Trim() + ";" + "UID='" + txtUserName.Text.Trim() + "';PWD='" + txtPassword.Text.Trim() + "';" + "Database='" + txtDatabase.Text.Trim() + "';charset=cp850;";
          AseConnection conn = new AseConnection(ConnectionString);
          AseCommand cmd = new AseCommand("exec sp_depends ["+sProcName+"]", conn);
          cmd.CommandType = CommandType.Text;
          AseDataAdapter adapter = new AseDataAdapter(cmd);
          conn.Open();
          adapter.Fill(ds);
          conn.Close();
  
          for (int i = 0; i &lt; ds.Tables[0].Rows.Count; i++)
          {
              if (ds.Tables[0].Rows[i]["type"].ToString() == "stored procedure")
              {
                  list.Add(ds.Tables[0].Rows[i]["object"]);
              }
          }
  
          return list;
  
      } 
  </code></pre>
  
  <p>this is snappit of my application till now after executing the prev code:
  <a href="https://i.stack.imgur.com/zmPv5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zmPv5.png" alt="enter image description here"></a></p>
  
  <p>the direct question is
  how get the dependencies for dbo.PSP_TC_129 and its childs if exists ...
  and for dbo.psp_ins_gl and its childs if exists ...
  and so on ...</p>
  
  <p>any help for accomplishing this task via showing all levels on TreeView.</p>
  
  <p>thanks in advance.</p>