Hi i have an excel sheet with headers,i want to populate those headers into a dropdown list...
can any one help me with the select statement and procedure
i am working on a code i dnt know whether its correct or not
DropDownList list = new DropDownList();
string connectionstring = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", Excelpath);
string query1 = String.Format("select * from [{0}]", DDlist.SelectedItem.Text);
// OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query1, connectionstring);
using (OleDbConnection conn1 = new OleDbConnection(connectionstring))
{
OleDbCommand odc1 = new OleDbCommand(string.Format(query1, conn1));
conn1.Open();
OleDbDataReader dr;
dr = odc1.ExecuteReader();
while (dr.Read())
{
list.Items.Add(dr[column.ColumnName].ToString());
}
dr.Close();
conn1.Close();
}
in this method i am geting an error at this line
dr = odc1.ExecuteReader();Error:ExecuteReader: Connection property has not been initialized.
can any one help mw with this, thanks in advance