1
I fill a dataGridView
via SQL and filling a dataTable
.
I’d like to associate a bindingNavigator
eastward dataGridView
.
I’m not getting it. 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’re in trouble on this line:
bindingNavigator1.BindingSource = dt;
That is, after the equals sign does not accept dt
. What’s the mistake?
Perfect. Thank you very much stderr.
– Jose Carlos Taveira