If you don't specify the "HDR=Yes" in your oleDBConn string, it would read the values right from the first row.
Sample snippet to read a excel worksheet into a DataTable.
OleDbDataAdapter oleDBAdapter = new OleDbDataAdapter();
OleDbCommand oleDBCommand = new OleDbCommand();
string connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + fullfilepath + "; Extended Properties =Excel 8.0;";
OleDboleDBConn oleDBConn = new OleDboleDBConn(connString);
oleDBConn.Open();
DataTable dtExcelData = new DataTable();
oleDBCommand = new OleDbCommand("SELECT * FROM [Sheetname$]", oleDBConn);
oleDBAdapter.SelectCommand = oleDBCommand;
oleDBAdapter.Fill(dtExcelData);
You could then send this data to your webservice, and then send the DataTable to the SQL Server.
However, if you need to read directly from the excel file and upload from your client itself, you could look at SQLBulkCopy
Sample snippet below:
string connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + fullfilepath + "; Extended Properties =Excel 8.0;";
using (OleDboleDBConn oleDBConn =
new OleDboleDBConn(connString))
{
OleDbCommand oleDBCommand = new OleDbCommand("SELECT * FROM [Sheetname$]", oleDBConn);
oleDBConn.Open();
using (DbDataReader dr = oleDBCommand.ExecuteReader())
{
string sqloleDBConnString = "Data Source=;Initial Catalog=Test;Integrated Security=True";
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqloleDBConnString))
{
bulkCopy.DestinationTableName = "sqlservertablename";
bulkCopy.WriteToServer(dr);
}
}
}