title: Reading Excel with C#
body: <p>I am trying to read an Excel file with C# and I keep getting this error: <code>oledbexception cannot update. database or object is read-only</code> on the line. Any ideas?</p>
  
  <pre><code>        string connStr = ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;
          SqlConnection conn = new SqlConnection(connStr);
          //file upload path
  
          string path = FileUpload1.PostedFile.FileName;
          //Create connection string to Excel work book
          string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileUpload1.PostedFile.FileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
          //Create Connection to Excel work book
          OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
          //Create OleDbCommand to fetch data from Excel
          OleDbCommand cmd = new OleDbCommand("Select [Coupon], [First Name], [Last Name] from [Sheet1$]",excelConnection);
          excelConnection.Open();
          OleDbDataReader dReader;
          dReader = cmd.ExecuteReader();
          SqlBulkCopy sqlBulk = new SqlBulkCopy(conn);
          //Give your Destination table name
          sqlBulk.DestinationTableName = "CPC_Coupons";
          sqlBulk.WriteToServer(dReader);
          excelConnection.Close();
  </code></pre>
  
  <p>Thanks!</p>