Untitled
unknown
plain_text
3 years ago
1.1 kB
10
Indexable
using MySql.Data.MySqlClient;
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;
namespace yon_database2
{
public partial class TestForm : Form
{
//Use your information
string cs = @"server=localhost;userid=admin;password=password;database=yon";
public TestForm()
{
InitializeComponent();
using var con = new MySqlConnection(cs);
con.Open();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM users", con);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
row.Cells[0].Value = reader[0];
row.Cells[1].Value = reader[1];
row.Cells[2].Value = reader[2];
dataGridView1.Rows.Add(row);
}
}
}
}
}
Editor is loading...