2

I'm using vb.net 2003 and I want to read excel file 2003 using OleDb Connection. But I have a problem when I'm putting the IMEX=1 property on the connection String. But when I have to romove this IMEX property, the system run without an error. Here is my connection string

xlsCon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & pathName & " ; Extended Properties=Excel 8.0;IMEX=1")

Can any one help me on how could i fix this error? I need to put IMEX property so that it tells the driver to always read intermixed (string, integer, date) data type on each cell.

Here is the error I've encountered.

System.Data.OleDb.OleDbException: Could not find installable ISAM.
   at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
   at System.Data.OleDb.OleDbConnection.InitializeProvider()
   at System.Data.OleDb.OleDbConnection.Open()
   at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
   at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at Production_Tracking_System.frmPMEFNATUpload.getUploadedData(String pathName) in D:\Legacy\Development\PTS 2 VSG-NAT\Forms\frmPMEFNATUpload.vb:line 434
Bryan
  • 1,245
  • 5
  • 22
  • 37

1 Answers1

7

If you use more than 1 extended property then the value tokens must be quoted, otherwise there is no way for the driver to distinguish them from the other non-extended properties in the connection string;

... pathName & ";Extended Properties=""Excel 8.0;IMEX=1"""
Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • Hi alex, extended property string is now okay but i seems that IMEX is not working. As I've uploaded the excel containing mixed data type per column, the other cell leave blank and not readed/output. Do you have any idea on how it comes? – Bryan Nov 15 '11 at 02:30