Advertisement
Guest User

Untitled

a guest
Aug 16th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. using MetroFramework.Forms;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using System.Data.SqlClient;
  12. using System.Threading;
  13. using MySql.Data.MySqlClient;
  14. using MetroFramework;
  15.  
  16. namespace FLPI_Admin_Tools
  17. {
  18. public partial class Panel : MetroForm
  19. {
  20. MySqlCommandBuilder cmbl;
  21. private MySqlDataAdapter sdaHFP;
  22. private DataTable table;
  23. MySqlConnection cn;
  24.  
  25. public Panel()
  26. {
  27. InitializeComponent();
  28. }
  29.  
  30. private void Panel_Load(object sender, EventArgs e)
  31. {
  32. var command = "SELECT * FROM players";
  33. var connection = @"datasource=localhost;port=3306;database=dp_frost;username=root;password=;SslMode=none";
  34. table = new DataTable();
  35. sdaHFP = new MySqlDataAdapter(command, connection);
  36. var commandBuilder = new MySqlCommandBuilder(sdaHFP);
  37.  
  38. foreach (DataRow item in table.Rows)
  39. {
  40. int n = metroGrid1.Rows.Add();
  41. metroGrid1.Rows[n].Cells[0].Value = item["ID"].ToString();
  42. metroGrid1.Rows[n].Cells[1].Value = item["UID"].ToString();
  43. metroGrid1.Rows[n].Cells[2].Value = item["NAME"].ToString();
  44. metroGrid1.Rows[n].Cells[3].Value = item["FACTION"].ToString();
  45. }
  46.  
  47. this.metroGrid1.DataSource = table;
  48. }
  49.  
  50. private void btnUpdate_Click(object sender, EventArgs e)
  51. {
  52. this.metroGrid1.EndEdit();
  53. sdaHFP.Update(table);
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement