DataTable dt = null; //Excel 2003 string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + fileName + ";" + "Extended Properties=Excel 8.0;"; OleDbConnection objConn = new OleDbConnection(connectionString); try { objConn.Open(); } catch { return null; } OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [" + parm.excelSheetName + "$]", bjConn); OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(); objAdapter1.SelectCommand = objCmdSelect; try { dt = new DataTable("ExcelTable"); objAdapter1.Fill(dt); objConn.Close(); } catch (Exception e) { throw e; } return dt>I am having a funny reaction when importing from Excel data into a dataset. This is the import function:
> ' Import from Excel > Public Function ImportFromExcel() As Boolean > Dim lcConnection As String = "" > > lcConnection = "provider=Microsoft.Jet.OLEDB.4.0; " + _ > "data source='" + cSource + "'; Extended Properties=Excel 8.0;" > > ' Assign the source directory > oConnection = New OleDbConnection(lcConnection) > > ' Select the data from Sheet1 of the workbook > oDataAdapter = New OleDbDataAdapter("Select * From [" + cWorkbook + "$]", oConnection) > > oDataSet = New DataSet > oDataAdapter.Fill(oDataSet) > > ' Record count > nCount = oDataSet.Tables(0).Rows.Count > > Return True > End Function >>