SHARE
TWEET

Untitled

a guest May 15th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 nota2
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void RefreshButton_Click(object sender, EventArgs e)
  22.         {
  23.             MySqlConnection connection = new MySqlConnection("server=localhost; user id=root; password=rootpassword; database=atestat; SSLMode=none");
  24.             string sql = "SELECT * FROM users";
  25.             MySqlCommand cmd = new MySqlCommand(sql, connection);
  26.             DataTable dt = new DataTable();
  27.             MySqlDataAdapter da = new MySqlDataAdapter(cmd);
  28.             da.Fill(dt);
  29.             grid.DataSource = dt;
  30.             connection.Close();
  31.  
  32.         }
  33.  
  34.         private void Button1_Click(object sender, EventArgs e)
  35.         {
  36.             MySqlConnection connection = new MySqlConnection("server=localhost; user id=root; password=rootpassword; database=atestat; SSLMode=none");
  37.             string sql = textBox1.Text;
  38.             MySqlCommand cmd = new MySqlCommand(sql, connection);
  39.             DataTable dt = new DataTable();
  40.             MySqlDataAdapter da = new MySqlDataAdapter(cmd);
  41.             da.Fill(dt);
  42.             grid.DataSource = dt;
  43.             connection.Close();
  44.         }
  45.     }
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top