Advertisement
Guest User

Untitled

a guest
Mar 29th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 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 System.Windows.Forms.DataVisualization.Charting;
  11. using MySql.Data.MySqlClient;
  12.  
  13. namespace WindowsFormsApp3
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public Form1()
  18. {
  19. InitializeComponent();
  20.  
  21. this.chart1.Series.Add("Blocks");
  22. this.chart1.Series[0].ChartType = SeriesChartType.Column;
  23.  
  24. chart1.ChartAreas[0].AxisX.LabelStyle.Angle = 45;
  25. chart1.ChartAreas[0].AxisX.Interval = 0.5;
  26.  
  27. string MySQLconnectionstring = "datasource=127.0.0.1;port=3306;username=root;password=;database=project";
  28. MySqlConnection connection = new MySqlConnection(MySQLconnectionstring);
  29. string qwerty = "SELECT * FROM `misdrijven_drenthe` WHERE 1";
  30.  
  31. MySqlConnection databaseconnection = new MySqlConnection(MySQLconnectionstring);
  32. MySqlCommand dbquery = new MySqlCommand(qwerty, databaseconnection);
  33. dbquery.CommandTimeout = 60;
  34. MySqlDataReader reader;
  35.  
  36. try
  37. {
  38. databaseconnection.Open();
  39. reader = dbquery.ExecuteReader();
  40.  
  41. if (reader.HasRows)
  42. {
  43. while (reader.Read())
  44. {
  45. string[] row = {reader.GetString(0), reader.GetString(1)};
  46. comboBox1.Items.Add(reader.GetString(0));
  47. }
  48. }
  49. }
  50. catch (Exception ex)
  51. {
  52. MessageBox.Show(ex.Message);
  53. }
  54. }
  55.  
  56. private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
  57. {
  58. Console.WriteLine("CSGO");
  59. }
  60.  
  61. public void UpdateChart()
  62. {
  63.  
  64. }
  65.  
  66.  
  67. private void Form1_Load(object sender, EventArgs e)
  68. {
  69.  
  70. }
  71.  
  72. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  73. {
  74. if (comboBox1.Text != "")
  75. {
  76. string MySQLconnectionstring =
  77. "datasource=127.0.0.1;port=3306;username=root;password=;database=project";
  78. MySqlConnection connection = new MySqlConnection(MySQLconnectionstring);
  79. string qwerty = "SELECT * FROM `misdrijven_drenthe` WHERE 1";
  80.  
  81. MySqlConnection databaseconnection = new MySqlConnection(MySQLconnectionstring);
  82. MySqlCommand dbquery = new MySqlCommand(qwerty, databaseconnection);
  83. dbquery.CommandTimeout = 60;
  84. MySqlDataReader reader;
  85. try
  86. {
  87. databaseconnection.Open();
  88. reader = dbquery.ExecuteReader();
  89. if (reader.HasRows)
  90. {
  91. while (reader.Read())
  92. {
  93. Globals.Gemeente = reader.GetString(0);
  94. }
  95. }
  96. databaseconnection.Close();
  97.  
  98.  
  99. }
  100. }
  101. }
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement