Add this code to the button click event handler.
private void btnConnect_Click(object sender, EventArgs e)
{
OdbcConnection oConn = new OdbcConnection();
oConn.ConnectionString = "Dsn=EXCEL";
OdbcCommand oComm = new OdbcCommand();
oComm.Connection = oConn;
oComm.CommandText = "Select * From [Feuil1$A1:C3]";
try
{
DataSet ds = new DataSet();
OdbcDataAdapter oAdapter = new OdbcDataAdapter(oComm);
oConn.Open();
oAdapter.Fill(ds);
dataGridView1.DataSource = ds;
dataGridView1.DataMember = ds.Tables[0].TableName;
label1.Text = "Connection established successfully!!!";
}
catch (IOException caught) { MessageBox.Show(caught.Message); }
catch (OdbcException caught) { MessageBox.Show(caught.Message); }
finally
{
oConn.Close();
}
}