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 nota2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void RefreshButton_Click(object sender, EventArgs e)
- {
- MySqlConnection connection = new MySqlConnection("server=localhost; user id=root; password=rootpassword; database=atestat; SSLMode=none");
- string sql = "SELECT * FROM users";
- MySqlCommand cmd = new MySqlCommand(sql, connection);
- DataTable dt = new DataTable();
- MySqlDataAdapter da = new MySqlDataAdapter(cmd);
- da.Fill(dt);
- grid.DataSource = dt;
- connection.Close();
- }
- private void Button1_Click(object sender, EventArgs e)
- {
- MySqlConnection connection = new MySqlConnection("server=localhost; user id=root; password=rootpassword; database=atestat; SSLMode=none");
- string sql = textBox1.Text;
- MySqlCommand cmd = new MySqlCommand(sql, connection);
- DataTable dt = new DataTable();
- MySqlDataAdapter da = new MySqlDataAdapter(cmd);
- da.Fill(dt);
- grid.DataSource = dt;
- connection.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement