The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I have a SQL table that contains some data related to our company structure. Basiclly its a table that holds role names as well as what role reports to what role.
From that we can build a org chart.
Can easily display this using the diagram component ?
Is the component smart enough to draw itself based on the sql data(suh as just binding the component to a dataset) or do I need to draw the diagram in code myself ?
ADAdministrator Syncfusion Team April 20, 2008 06:04 PM UTC
Hi Heath,
Thank you for using Syncfusion products.
Display OrgChart based on data from SQL.
Please refer the OrgLayout sample in Syncfusion\EssentialStudio\6.2.0.40\Windows\Diagram.Windows\Samples\2.0\Demo Diagrams\OrgLayout\ demonstrates how to draw the diagram layout by retrieving the informations from an Access database. Referring to the sample's MainForm class InitializeDiagramFromDatabase(..) and ReadEmployeeDataFromDatabase(..) methods demonstrate about how to read data from an Access database.
Essential Diagram also supports reading data from a SQL database. Using System.Data.SqlClient.SqlConnection instead of the OleDbConnection will let the user to read the data from the sql database.
Here is a sample code snippet to read data from a Sql Database:
[C#]
private Hashtable ReadEmployeeDataFromSql() {
Hashtable htemployees = new Hashtable();
string connectionstring = "workstation id=SYNCCHN;packet size=4096;user id=sa;password=pwd;data source=SYNCCHN;persist security info=False;initial catalog=tempdb"; // Query to select all records from the Org.mbd database string orgdbselectquery = "SELECT EmployeeID, Name, ManagerID FROM TempEmployees"; System.Data.SqlClient.SqlConnection sqlConnection = new SqlConnection(connectionstring); SqlCommand orgdbcommand = new SqlCommand(orgdbselectquery, sqlConnection); // Create a connection to the datasource sqlConnection.Open(); // Execute the query command to build the data reader SqlDataReader orgdbreader = orgdbcommand.ExecuteReader(); // Extract employee data from the reader while(orgdbreader.Read()) { object[] employeedata = new object[3]; int count = orgdbreader.GetValues(employeedata);
// Create an Employee instance to represent each employee Employee emply = new Employee(); emply.EmployeeID = employeedata[0].ToString(); emply.EmployeeName = (string)employeedata[1]; if(count == 3) emply.ManagerID = employeedata[2].ToString(); htemployees.Add(emply.EmployeeID, emply); } // Close the reader orgdbreader.Close(); // Close the connection orgdbcommand.Connection.Close();
return htemployees; }
Essential diagram does not have support for directly binding the diagram component to a database. We need to read the data from the DataReader and create instanace for Employee object in the Organization.