Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:31:43+00:00 2026-06-08T08:31:43+00:00

I’m using working in a C# winforms .NET4 application My goal is to populate

  • 0

I’m using working in a C# winforms .NET4 application

My goal is to populate a chart control from a specific SQL query.

“SELECT height from person”

simple query but im not sure the best way to get this the query result into the chart control.

Heres what i have so far:

private void button1_Click(object sender, EventArgs e)
        {         
            SqlConnection mainconnection = new SqlConnection("Data Source=commandhq;Initial Catalog=projecttest;Integrated Security=True");
            mainconnection.Open();
            string query = "SELECT height from persons";
            SqlCommand querycommand = new SqlCommand(query, mainconnection);
            SqlDataReader querycommandreader = querycommand.ExecuteReader();


            Series thesqlresultsplease = new Series();

            //Populate series with results from the sql query

            chart1.Series[0].XValueMember = thesqlresultsplease.XValueMember; //will this work?

        }

My issues are:

How do i get the results from the sqldatareader into the series.
If you know of a much better way of going about this please let me know. Im about to start a project so this would be very helpful.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:31:45+00:00Added an answer on June 8, 2026 at 8:31 am

    Start with this:

    while (querycommandreader.Read()) 
    {
        chart1.Series[0].Points.AddY(reader.GetDouble(0));
    }
    

    Depending on the Sql Server data type of your “HEIGHT” column, you might have trouble with the GetDouble part. So if you do, let me know the data type and we’ll get it right.

    The Read() method returns a boolean – true if there are still records being read, false if you’ve passed the last on in the set. That’s why you can simply use while(querycommandreader.Read()) and in the loop’s block do something with each row in the set.

    The series’ Points collection has an AddY method that just takes a double and adds a point to the series. The double we’re passing to it comes from column zero of the current record of the reader. That’s probably the easiest way to accomplish what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.