i am trying to read Data from an Excel sheet into a SQL Database.
The attached code works, except for the Selection string. It does not allow me to use the "Print Area" as a selection source.
Does anybody know how i can use the Print Area as a selection source?
OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + @"c:/temp/lpa.xls" + ";"
+ "Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"");
string SQLString = @"Select * FROM [RR Door LH$.Print_Area]";
OleDbCommand DBCommand = new OleDbCommand(SQLString, DBConnection);
IDataReader DBReader = DBCommand.ExecuteReader();
using (IDataReader DBReader = DBCommand.ExecuteReader())
string SQLCOnnectionString = @"Data Source=localhost\SQLEXPRESS; Initial Catalog=Test; Integrated Security=True";
using (SqlBulkCopy bulkcopy = new SqlBulkCopy(SQLCOnnectionString))
bulkcopy.DestinationTableName = "ExcelData";
GridView1.DataSource = DBReader;