I am having difficulty in constructing SQL Commands in VB.Net wherein my project is connected to Excel via OLEDB.
Select * From [Sheet$]
This SQL Command works but whenever I try to add another SQL Command WHERE so that I could filter the data and I only wanted to be shown.
I have headers in my excel file, the Name header is the 4th column equivalent to Column letter: D.
Select * From [Sheet$] Where Name='Xander'
it doesn't work, it shows nothing. What is the correct 'WHERE' SQL Command for Excel to OLEDB Connection?
By the way this is the code I am working on
Dim conn As OleDbConnection
Dim adapt As OleDbDataAdapter
Dim dts As DataSet
Dim excel As String = My.Settings.DefaultDirectory
conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excel + ";Extended Properties=Excel 12.0;")
conn.Open()
adapt = New OleDbDataAdapter("Select * from [Sheet$] where NAME='Xander'", conn)
dts = New DataSet
adapt.Fill(dts, "[Sheet$]")
DataGridView1.DataSource = dts
DataGridView1.DataMember = "[Sheet$]"
conn.Close()
CellHeaderthe header/column?Select * from [Sheet$] Where [NAME]='Xander'