TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kishore Konatham
NA
63
7.5k
How to add two tables data to the chart from the database?
Aug 22 2019 2:15 AM
I've tried this. Please let me know the alternative
private void Form1_Load(object sender, EventArgs e)
{
string c = @"Data Source=mydts; Initial Catalog=SampleDB; Integrated Security=True";
SqlConnection conn = new SqlConnection(c);
conn.Open();
//Adding Income from Transactions table
string query = "select Income from Transactions";
SqlCommand cmd = new SqlCommand(query, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
chart1.DataSource = ds;
chart1.Series["Income"].XValueMember = "Income";
chart1.Series["Income"].YValueMembers = "Income";
//Adding Expenses from Transactions1 table
string query1 = "select Expenses from Transactions1";
SqlCommand cmd1 = new SqlCommand(query1, conn);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
chart1.DataSource = ds1;
chart1.Series["Expenses"].XValueMember = "Expenses";
chart1.Series["Expenses"].YValueMembers = "Expenses";
conn.Close();
}
Why can't it add two values from differet tables?
Thank you.
Reply
Answers (
1
)
Creating a licensing for .Net windows application
How to get the entries where the difference between two col