Urgent!!!Finding Excel sheet names dynamically in VB.NET?
My question is If user changes this sheet 1 name to "ABC" and uploaded.
how the following code works? it goes to error handling. Please can you let me know how to track sheet names or how retreive data for this condition dynamically.
Waiting for reply. Thanks in advance.
Ram
Public GetDataFromExcel() as DataSet
Dim sSheet as string = "Sheet1"
Dim myDataset As New DataSet()
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("/excelreading/") & "excel/" & strFileNameOnly & ";" & _
"Extended Properties=Excel 8.0;"
Dim myData As New OleDbDataAdapter("SELECT * FROM [" & sSheet & "$]", strConn)
myData.Fill(myDataset)
Return myDataset
End Sub

