LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default External table is not in the expected format

I have a default.htm file which has some rows of data along with some images.
My intention is to read this rows of data.

If I somply rename default.htm to default.xls and excute the below code , it
gives error "External table is not in the expected format."

If I open a default.htm and manually save a default.xls the below lines of
code executes sucessfully.

How do I deal with this problem.

CODE START-------------
Dim mExcelFile As String
mExcelFile = "C:\Projects\mamour\AggValueHistory\default.xl s"
Dim sourceConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & mExcelFile & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
Dim sourceSQL As String = "SELECT * FROM Sheet1$"

'now do the work
Dim sourceCon As New OleDbConnection(sourceConStr)


Dim sourceCommand As New OleDbCommand(sourceSQL, sourceCon)
Try
sourceCon.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

Dim sourceReader As OleDbDataReader
Dim a As String
Dim b As Integer
Dim c As String
Dim d As String
Try
sourceReader = sourceCommand.ExecuteReader()

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

While sourceReader.Read() 'for each row from source
Try
For i As Integer = 0 To sourceReader.FieldCount - 1
'load values into parameters

a = sourceReader.Item(0)
b = sourceReader.Item(1)
c = sourceReader.Item(2)
d = sourceReader.Item(3)
console.write(a & b & c & d)
Next
Catch ex As Exception 'OleDbException
Dim strmsg As String
messagebox.showex.message
End Try
End While
sourceReader.Close()
sourceCon.Close()
End Sub

CODE END-------------

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
External table is not in the expected format. Amy E. Baggott Excel Discussion (Misc queries) 0 May 8th 09 04:26 PM
DATE FORMAT IN PIVOT TABLE FROM EXTERNAL DATA SOURCE uncreative Excel Discussion (Misc queries) 2 February 23rd 07 04:51 PM
Pivot Table Wizard Error (Expected 52) Guest Excel Discussion (Misc queries) 0 April 28th 06 10:10 PM
LOOKUP function not returning expected value - Using vector_lookup format JerichoForce Excel Worksheet Functions 2 April 18th 06 10:45 AM
ADO - Excel - External table is not in the expected format Adriana Camargo Excel Programming 3 May 21st 04 01:52 PM


All times are GMT +1. The time now is 06:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"