Below is the code I have been using to pull all info from a specified Excel Sheet. Its working fine as long as the sheet I want data from is called "Sheet1".
I now need to be able to programatically determine the name of the first sheet in the Excel file as this my dynamically change. Can someone let me know how to do this?
Dim sourceConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & importString & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
Dim SheetName As String = "Sheet1"
Dim columnsmade As Boolean = False
If Not SheetName.EndsWith("$") Then
SheetName &= "$"
Dim sourceSQL As String = "SELECT * FROM [" & SheetName & "]"
Dim sourceCon As New System.Data.OleDb.OleDbConnection(sourceConStr)
Dim sourceCommand As New System.Data.OleDb.OleDbCommand(sourceSQL, sourceCon)
Dim sourceReader As System.Data.OleDb.OleDbDataReader