I have little problem with DataGridView
when I try to render MySL data inside the grid.
First, I use this mysql class
Next, I create model classes with methods which hold a MySql query. In that class I am using DI
to inject Db
class in to the following:
public class Option
{
private readonly Database db;
public Option()
{
db = new Database();
}
public DataTable ListAll()
{
return db.query("SELECT * FROM options");
}
}
Next in the form class I try this ListAll
method to bind
and set in dataSource
:
private void MainWindow_Load(object sender, EventArgs e)
{
Options o = new Options();
BindingSource bind = new BindingSource();
bind.DataSource = o.ListAll();
dataGridView1.DataSource = bind;
}
Can someone show me what am I doing wrong here?