Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in E:\HostingSpaces\ZNETNEW683\\wwwroot\support\Sources\Load.php(225) : runtime-created function on line 3
Create Organization Chart from Database/ODBC
Unifosys Business Engineering Support
May 26, 2022 *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: March 11, 2015: Chart4.NET 2015 (5.1) supports large organization charts, PDF Rendering (Desktop/ASP.NET), 3D, Planer views, Navigational Tree and Data Search:
   Home   Help Search Login Register  
Pages: [1]
Author Topic: Create Organization Chart from Database/ODBC  (Read 8601 times)
« on: January 21, 2011 »


You can download database sample source code from the following links:


Webform Demo & Downloads:

N.B: The explanation here is based on Microsoft SQL Server, but equally applies to any DBMS through Open Database Connectivity.

Refer the following link for sample table and sample data:

1. First you should create a database named 'test' in MSSQL Server.
2. Then run the sample SQL script (See link above) against the database to create the sample table.
3. Open the table in MSSQL Management Studio and paste the sample data (See link above).
4. Test database connection. For that download source code of the online demo from the following link:
5. Replace the code in heHierarchyData event in the sample source code as follows (You connection-string may vary according to your configuration):

        protected void HierarchyWeb1_heHierarchyData( object sender, EventArgs e )
            System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection( );
            conn.ConnectionString = "Driver={SQL Server};Server=.\\SQLEXPRESS;Database=test1;Trusted_Connection=Yes;";
            //Check sResult for any errors
            string sResult = HierarchyWeb1.hpcData.LoadFromDatabase(
                    conn, "Parc", "id", "pid", "txt", "", "", "tooltip", "imagefile" );
            HierarchyWeb1.hpcData.ExpandAll( );//expand all nodes

  • Please check sResult variable to get a clue, if there is any connection error.
  • You have to provide data in the heHierarchyData event itself. For that, please do any one of the following:
    1. Download the online sample source code and just replace HierarchyWeb1_heHierarchyData() with the above mentioned code.
    2. If you are making a fresh page/site/application, link the event handler to this function, either by typing in the aspx page (bold thing below) or through Visual Studio designer.

           <cc1:HierarchyWeb ID="HierarchyWeb1" runat="server" Height="400px" OnheHierarchyDraw="HierarchyWeb1_heHierarchyDraw"
                Style="z-index: 101; left: 10%; position: relative;" Text="MK" Width="700px" OnInit="HierarchyWeb1_Init" OnheHierarchyData="HierarchyWeb1_heHierarchyData"/>

  • For winforms, it can be in any event including Form_Load, but do a HierarchyWin1.Refresh(), if it is inside a button event for example.
« Last Edit: May 25, 2011 by Admin » Logged
Pages: [1]
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
© 2008-