title: Import excel sheet using jet.oledb.4.0 , setting first row as column name
body: <p>i am trying to import an excel file into a datatable in using <strong>Jet.Oledb</strong>. Here is my code: </p>
  
  <pre><code>            string sourceConstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + HttpContext.Current.Server.MapPath("~/" + fileName) + "';Extended Properties='Excel 8.0;HDR=No;IMEX=1'";
              OleDbConnection con = new OleDbConnection(sourceConstr);
              OleDbCommand oleDbCmd = new OleDbCommand();
              con.Open();
              oleDbCmd.Connection = con;
              DataTable dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
  
              string firstExcelSheetName=dt.Rows[0][2].ToString();
              string query = "select * from [" + firstExcelSheetName + "]";
              OleDbDataAdapter data = new OleDbDataAdapter(query, con);
              data.TableMappings.Add("Table", "dtExcel");
              data.Fill(dtExcel);
  </code></pre>
  
  <p>In the excel file, first row has the columnname. but my datatable is getting (f1,f2,f3,...) as column name and first row of the excel file as first row. So i can guess I have to tell that the first row contains columnName. But how can i make it happen?</p>