Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

I have this code:
Dim conz As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Bdados\CV_PARTS.accdb;Persist Security Info=False")
Dim cmd As New OleDbCommand("SELECT * FROM PECAS_IN WHERE Fornecedor = ?)", conz)


After this I create a parameter and assign it to the text of a combobox. Supposing I want to retrieve all data by leaving the combobox empty what code should I use? I tried:
Dim cmd As New OleDbCommand("SELECT * FROM PECAS_IN WHERE (Fornecedor = ? OR Fornecedor Like "*")


But it does not work. What is the correct syntax?

Thank you.
Octavio
Posted
Updated 24-Jun-11 6:23am
v2

First of all, you can't use double quote like this in VB.

Try
Dim cmd As New OleDbCommand("SELECT * FROM PECAS_IN WHERE (Fornecedor = ? OR Fornecedor Like ""*""")
 
Share this answer
 
Hello.

I tried your solution but it still does not work...

Octavio
 
Share this answer
 
Hi.

I found out!

Dim cmd As New OleDbCommand("SELECT * FROM PECAS_IN WHERE Fornecedor LIKE '%' + ? + '%'"


It's a bit weird but it does work. Nothing like using SQL on Oracle, which is what i'm used to.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900