Diagram from Sample

Hello,

How to generate à diagram from a database ?

thanks a lot

3 Replies

CU cuongnq July 27, 2007 10:06 AM UTC

Very Easy,
View The OrgLayout sample shows an application that uses a DiagramWebControl to display an organizational chart using employees data sourced from:

1. An Access database
2. An XML format datafile

In: diagram.web\Samples\2.0\OrgLayout


NI Nico July 27, 2007 03:14 PM UTC

In 5 version i can't find those files...


J. J.Nagarajan Syncfusion Team July 27, 2007 09:00 PM UTC

Hi Nico,

If you want to load the diagram from the data base then please refer to the following code snippet

// Connection string for the Org.mdb Access database
string connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + datasrc + ";";
OleDbConnection orgdbconnection = new OleDbConnection(connectionstring);

orgdbconnection.Open();
// Query to select all records from the Org.mbd database
string orgdbselectquery = "SELECT EmployeeID, Name, ManagerID FROM Employees";
OleDbCommand orgdbcommand = new OleDbCommand(orgdbselectquery, orgdbconnection);
// Create a connection to the datasource

// Execute the query command to build the data reader
OleDbDataReader 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();

Please refer to our OrgLayout sample(My Documents\Syncfusion\EssentialStudio\5.1.0.51\Web\diagram.web\Samples\2.0\OrgLayout) for more details. You can see the data base file in "App_Data" folder of this application. I have attached the sample for your reference.

OrgChartSample.zip

Please refer to it and let me know if you have any questions.

Thanks,
Nagaraj

Loader.
Up arrow icon