On this button click it should load the contents of an excel file into a dataGrid but instead am getting the error mentioned in the title of this post. What is it that am doing wrong?
private void button7_Click_2(object sender, EventArgs e)
{
string path = "C:\\Users\\jdavis\\Downloads\\Pharmacies\\CrossReferencing v3\\CrossReferencing\\\bin\\Debug\\cross_check.xls";
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + path + ";Extended Properties=' Excel 8.0;HDR=Yes;IMEX=1;';");
OleDbCommand command = new OleDbCommand
(
"SELECT"+"FROM [cross_check]",con
);
DataSet cross = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
adapter.Fill(cross);
dataGridView2.DataSource = cross.Tables[0];
}
}