I'm trying to import an Excel file into a datatable. It works fine most of the time. However, I get this error when there are more than 255 columns in the Excel file. The columns are empty (after about 6 or so), but since they've been formatted it sees them anyway.
My question is, is there any way around this? Can I limit the amount of columns somehow? Unfortunately, I can't just remove the columns in the Excel document, as this is being designed for users to upload documents, so I have to account for this possibility (even though most of the time there will be maximum 20 columns).
Here is the code I'm using:
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _filePath + ";Extended Properties=""Excel 8.0;HDR=No;IMEX=1"";"
Dim xlConn As New OleDbConnection(connectionString)
Dim cmd As New OleDbCommand("SELECT * FROM [" + GetWorksheetName(xlConn) + "]", xlConn)
Dim da As New OleDbDataAdapter(cmd)
The exception is thrown on the "da.Fill(
View Complete Post