SQL Statement Question (VB6)
Hello,
I have an SQL question. I am using VB6 in an app, and want to use the ADODC control to search my data (which is an Excel 2000 file).
The SQL statement I am trying to do would search fields called Product #1, Product #2, and Product #3. I was trying the following code, but it is not working.
Private Sub Command1_Click()
Adodc1.RecordSource = "Select * from [Sheet1$] Where [Product #1] = "Widget (CD) And [Product #2] = "Widget (CD) And [Product #3] = "Widget (CD)"
Adodc1.Refresh
End Sub
Any ideas or SQL tutorial links would be appreciated. Thank you!
Re: SQL Statement Question (VB6)
Moved to Database Development forum
You need to use single quotes around text values, instead of double quotes as you have, eg:
VB Code:
Adodc1.RecordSource = "Select * from [Sheet1$] Where [Product #1] = [b][u]'[/u][/b][u][/u]Widget (CD)[b][u]'[/u][/b][u][/u] And [Product #2] = [b][u]'[/u][/b][u][/u]Widget (CD)[b][u]'[/u][/b][u][/u] And [Product #3] = [b][u]'[/u][/b][u][/u]Widget (CD)[b][u]'[/u][/b][u][/u]"
As for tutorials, see the FAQ's at the top of this forum - I'd specifically advise reading the article about why bound controls are bad.