I fill in a dataGridView
via SQL and fill in a dataTable
.
I would like to associate a bindingNavigator
with this dataGridView
.
I can not. Follow the code.
string arquivo = System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "Sistema_de_provas.accdb";
OleDbConnection cn = new OleDbConnection();
cn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + arquivo + ";Jet OLEDB:Database Password=; Persist Security Info=False;";
cn.Open();
OleDbCommand com = new OleDbCommand();
com.Connection = cn;
com.CommandText = "SELECT * FROM PROVAS";
OleDbDataReader dr = com.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
dataGridView2.DataSource = dt;
bindingNavigator1.BindingSource = dt;
cn.Close();
You have a problem with this line:
bindingNavigator1.BindingSource = dt;
That is, after the equal sign does not accept dt
. What is wrong?