Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using MySql.Data.MySqlClient;
- namespace WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string connect = "datasource=localhost;port=3306;username=root;password=";
- MySqlConnection conn = new MySqlConnection(connect);
- MySqlCommand comm = new MySqlCommand("Select * from test.buah;",conn);
- MySqlDataReader reader;
- try
- {
- conn.Open();
- reader = comm.ExecuteReader();
- while (reader.Read())
- {
- this.chart1.Series["buah"].Points.AddXY(reader.GetString("nama_buah"), reader.GetInt32("jumlah_buah"));
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void chart1_Click(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement