Update:
You can download database sample source code from the following links:
Winform:
http://unifosys.com/hierarchy-chart/Create_Organization_Chart_From_Database_Sample.html
Webform Demo & Downloads:
http://organization.unifosys.com/Create_Organization_Chart_From_Database_Sample_WebForm.aspx
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:
http://unifosys.com/chart4.net/html/T_UnifoChart_Hierarchy_HierarchyData.htm1. 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:
http://organization.unifosys.com/demo.aspx5. 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
}
N.B:
- 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.
OR
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.