1
Answer

Problem in exporting data to chart

darma teja

darma teja

12y
1.4k
1
Hi,

I would like to make chart with taskname (on X-axis) and timetakenfortheTask (on y-axis).

in my database i have data as:
Taskname   timetakenfortheTask(hrs)
Writing           1:00
printing          2:30
delivery          5:00

I wrote code like this:

With the below code i am getting all task names on x-axis. But i am not getting "timetakenfortheTask" on y-axis with times.

 chart1.Enabled = true;
            con.Open();
            chart1.DataSource = null;

            SqlCommand chartcmd = new SqlCommand("select taskname, timetakenfortheTask  from Time_sheet where Name='" + cmbEmpnam.Text + "';", con);
            chartcmd.Connection = con;
            SqlDataAdapter chartada = new SqlDataAdapter(chartcmd);
            DataSet ds = new DataSet();

            chartada.Fill(ds);
            DataView source = new DataView(ds.Tables[0]);

            chart1.DataSource = source;

            chart1.Series[0].XValueMember = "taskname";
            chart1.Series[0].YValueMembers = "timetakenfortheTask";

            chart1.DataBind();

            con.Close();



Advance thanks,

Darma
Answers (1)