Advertisement
Guest User

code

a guest
Dec 14th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MySql.Data.MySqlClient;
  11.  
  12. namespace WindowsFormsApplication2
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void Form1_Load(object sender, EventArgs e)
  22. {
  23.  
  24. }
  25.  
  26. private void button1_Click(object sender, EventArgs e)
  27. {
  28. string connect = "datasource=localhost;port=3306;username=root;password=";
  29. MySqlConnection conn = new MySqlConnection(connect);
  30. MySqlCommand comm = new MySqlCommand("Select * from test.buah;",conn);
  31. MySqlDataReader reader;
  32.  
  33. try
  34. {
  35. conn.Open();
  36. reader = comm.ExecuteReader();
  37.  
  38. while (reader.Read())
  39. {
  40. this.chart1.Series["buah"].Points.AddXY(reader.GetString("nama_buah"), reader.GetInt32("jumlah_buah"));
  41. }
  42. }
  43. catch (Exception ex)
  44. {
  45. MessageBox.Show(ex.Message);
  46. }
  47. }
  48.  
  49. private void chart1_Click(object sender, EventArgs e)
  50. {
  51.  
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement