Create Family Tree Chart from Access Database using C# and VB.Net in ASP.Net

Last Reply on May 24, 2017 09:13 AM By AnandM

Posted on May 24, 2017 05:17 AM

I want to the database form of your family tree script. I want to use access database instead of sql database. How can I change th codes? I tried to change the codes. But I am getting the error "undefined". What is the problem?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Configuration;
using System.Data.OleDb;
using System.Data;

public partial class _Default : System.Web.UI.Page

    protected void Page_Load(object sender, EventArgs e)
        OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; DATA Source=" + Server.MapPath("app_data/familytree.accdb"));
    public static List<object> GetChartData()
        string query = "SELECT MemberId, Name, ParentId";
        query += " FROM FamilyHierarchy";
        string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        using (OleDbConnection con = new OleDbConnection(constr))
            using (OleDbCommand cmd = new OleDbCommand(query))
                List<object> chartData = new List<object>();
                cmd.CommandType = CommandType.Text;
                cmd.Connection = con;
                using (OleDbDataReader sdr = cmd.ExecuteReader())
                    while (sdr.Read())
                        chartData.Add(new object[]
                            sdr["MemberId"], sdr["Name"], sdr["ParentId"]
                return chartData;



You are viewing reply posted by: AnandM on May 24, 2017 09:13 AM.
Posted on May 24, 2017 09:13 AM
Instead of saying thanks mark the reply or replies(if multiple) that helped as Answer.