The Excel table must be in the format. Otherwise, the query fails.
[Vb]
Imports System. Data. OleDb
Public Class Form1
Private Sub button#click (ByVal sender As System. Object, ByVal e _
System. EventArgs) Handles Button1.Click
Dim ConnectiongString As String
Dim Path As String
Dim Dialgo As OpenFileDialog = New OpenFileDialog
Dim Connection As OleDbConnection = New OleDbConnection
Dim adapter As OleDbDataAdapter
Dialgo. Filter = "Excel Document (*. xls) | *. xls"
Dialgo. ShowDialog ()
Path = Dialgo. FileName
ConnectiongString = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source = "_
+ Path + "; Extended Properties = 'excel 8.0; HDR = no; IMEX = 0 '"
Connection. ConnectionString = ConnectiongString
Connection. Open ()
Adapter = New OleDbDataAdapter ("SELECT * FROM [Sheet1 $] Where B = 4 ",
Connection)
Adapter. Fill (DataSet1)
MsgBox (DataSet1.Tables (0). Rows (0). Item (0 ))
Connection. Close ()
End Sub
End Class
From TX_OfficeDev's column