private void InitValues(string sql) { this.tbSQL.Text = sql; // Fill out the tables, columns and parameters // suppress redraw until tree view is complete tvTablesColumns.BeginUpdate(); // Get the schema information List <SqlSchemaInfo> si = DesignerUtility.GetSchemaInfo(_Draw, _DataSource); if (si != null && si.Count > 0) { TreeNode ndRoot = new TreeNode("Tables"); tvTablesColumns.Nodes.Add(ndRoot); if (si == null) // Nothing to initialize { return; } bool bView = false; foreach (SqlSchemaInfo ssi in si) { if (!bView && ssi.Type == "VIEW") { // Switch over to views ndRoot = new TreeNode("Views"); tvTablesColumns.Nodes.Add(ndRoot); bView = true; } // Add the node to the tree TreeNode aRoot = new TreeNode(ssi.Name); ndRoot.Nodes.Add(aRoot); aRoot.Nodes.Add(""); } } // Now do parameters TreeNode qpRoot = null; foreach (DataRow dr in _QueryParameters.Rows) { if (dr[0] == DBNull.Value || dr[1] == null) { continue; } string pName = (string)dr[0]; if (pName.Length == 0) { continue; } if (qpRoot == null) { qpRoot = new TreeNode("Query Parameters"); tvTablesColumns.Nodes.Add(qpRoot); } //Changed from forum, user:Jaimi http://www.fyireporting.com/forum/viewtopic.php?t=870 if (pName[0] != '@') { pName = "@" + pName; } // Add the node to the tree TreeNode aRoot = new TreeNode(pName); qpRoot.Nodes.Add(aRoot); } tvTablesColumns.EndUpdate(); }