Click here to Skip to main content
15,936,119 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hi,

I need to load a win forms chart with data from my sql db
and i want to use this type of structure(I'm still new with charts)
This is the method I use when populating controls mostly...
The stored proc is not a problem, only the code behind

Can anyone please help me with this code?

C#
clsConnection conn = new clsConnection();

                using (SqlCommand sqlcomm = new SqlCommand())
                {
                    SqlDataReader sqlread;

                    sqlcomm.Connection = conn.connection;
                    sqlcomm.CommandType = CommandType.StoredProcedure;
                    sqlcomm.CommandText = "usp_LoadChart";
                    sqlcomm.Parameters.Add("@ParameterExample", SqlDbType.NVarChar, 50).Value = cboExample.Text.ToString().Trim();

                    sqlread = sqlcomm.ExecuteReader();

                    while (sqlread.Read())
                    {
                       ....
                    }
                    sqlread.Dispose();
                    sqlread.Close();
                }
Posted
Updated 31-Jan-12 19:37pm
v3
Comments
Christian Graus 1-Feb-12 1:31am    
What is wrong with it ? This code reads data, it does not interact with a chart. What is the issue ? What charts are you using ?
Ben Paxton 1-Feb-12 1:33am    
Bar chart integrated with visual studio 2010
Sergey Alexandrovich Kryukov 1-Feb-12 1:43am    
And..?
--SA
Ben Paxton 1-Feb-12 1:51am    
what should I do/change this code to be able to populate the chart
ZurdoDev 1-Feb-12 9:20am    
You need to read the MSDN online help for charts. You need to setup the datasource, databind it, setup your series, your axis, labels, and data points.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900