Hi Dave Kreskowiak,
Windows 7, 32 bit, MS Office 2007 in my system but the Excel am using for this purpose is a template from Webtma, USA company designed as a database file and is MS Excel 1997-2003.
Thanx for the reply. The error doesn't point to any particular line of code instead whenever i run d program and set HDR=YES, it's just brought out d error and return blank output.
I've tried different ways, i even created a function for the connection string, but still not wotking.
My codes below:
<pre lang="vb">Private _blnMixedData As Boolean = True
Private _blnHeaders As Boolean = True</pre>
Private Function ExcelConnection() As String
Return "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & SVTest & ";" & "Extended Properties=" & Convert.ToChar(34).ToString() & "Excel 8.0;" & "HDR=YES;" & "Imex=2;" & Convert.ToChar(34).ToString()
End Function
Private Function ExcelConnection() As String
Return "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & SVTest & ";" & "Extended Properties=" & Convert.ToChar(34).ToString() & "Excel 8.0;" & ExcelConnectionOptions() & Convert.ToChar(34).ToString()
End Function
Private Function ExcelConnectionOptions() As String
Dim strOpts As String = ""
If Me.MixedData = True Then
strOpts += "Imex=2;"
End If
If Me.Headers = True Then
strOpts += "HDR=Yes;"
Else
strOpts += "HDR=No;"
End If
Return strOpts
End Function
Private Sub RetrieveSheetnames()
Try
Me.ComboBox1.Items.Clear()
If _exr IsNot Nothing Then
_exr.Dispose()
_exr = Nothing
End If
_exr = New ExcelReader()
_exr.ExcelFilename = ExcelFilename
_exr.Headers = True
_exr.MixedData = True
Dim sheetnames As String() = Me._exr.GetExcelSheetNames()
Me.ComboBox1.Items.AddRange(sheetnames)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
End Try
End Sub
Your kind assistance would be highly appreciated.
Thanks alot