Click here to Skip to main content
12,892,729 members (47,242 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
Hi everyone!

I have trouble putting together a chart with the contents of a data table that is basically as sex, marital status, age, and DATE . Im working with a bar chart or column chart, but I can't make it work like I want. What im looking for is that each column of the chart has his name on the bottom (column name of the database) and on the header (think are called labels) display the results of a sql query but if in that query exist different data like for example in the SEX column there are two possibilites, MAN or WOMAN and I need that if there 2 results with MAN and 3 results with WOMAN on the column chart SEX header this values have to appear there in the header of that column. I get data from a SQL Server Express DB.

This is the query that I have to get the data in the chart:

SqlCommand cmd2 = new SqlCommand(string.Format("SELECT SEX, MARITAL,AGE,DATE FROM TEST WHERE (SEX IN (" + sex + ")) AND (MARITAL IN (" + marital + ")) AND (AGE (" + age + ")) AND (DATE IN (" + date + "))"), con1);
            SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
            DataSet ds2 = new DataSet();
            chart1.DataSource = da2;
            chart1.Visible = true;

In case that you don't understand me, this is what i'm looking for (made with photoshop :p):[^]

I really search all the webs related with chart in c# winforms but i can't find any solution like this.

Can anyone please help me to make the code like the chart example using the binding from my bbdd.

Thanks for the answers!.

Kind regards.
Posted 20-Dec-12 9:42am
Updated 20-Dec-12 10:39am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Have you checked this link mschart[^] and sample-using-mschart-in-c-sharp[^]

there you can find more samples different types of charts as well.
Abhishek Pant 22-Dec-12 10:41am
jibesh 22-Dec-12 19:30pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

this might help you-
Write Your Own Bar Chart Winforms User Control[^]
Windows Charting Application[^]

or you can follow this link

hope it helps!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170424.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100