SELECT ALL

I have an SQL query in an OleDBCommand in VB.NET 2003 that retrieves data from an Access database. It looks like this:

"SELECT * FROM Files WHERE File_Num = 'R00001'"

This works perfectly. Now, if I change it to

"SELECT * FROM Files WHERE File_Num = %"

It returns nothing. What I'm trying to do is to return all rows where File_Num is equal to anything. I know that I can just say:

"SELECT * FROM Files"

but the problem is that I actually have the File_Num as a parameter in a OleDbSelectCommand because most of the time I will want to filter by a particular File_Num, but sometimes I won;ty want to. I will want to display all rows with any File_Num. What do I pass the parameter in such cases? Looks like % doesn't work.
SETPAsked:
Who is Participating?
 
RonaldBiemansConnect With a Mentor Commented:
Use it with the like operator


"SELECT * FROM Files WHERE File_Num like '%'"

or maybe  just try

"SELECT * FROM Files WHERE File_Num = '%'"




0
 
DhaestCommented:
"SELECT * FROM Files WHERE File_Num Like '%'"
0
 
Arthur_WoodCommented:
change:

SELECT * FROM Files WHERE File_Num = %  

to:

SELECT * FROM Files WHERE File_Num like '%'

AW
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Arthur_WoodCommented:
too slow... just shows the great minds think alike LOL  ;-)

AW
0
 
YZlatCommented:
"SELECT * FROM Files WHERE Not IsNull(File_Num)"

or

"SELECT * FROM Files WHERE File_Num Not IsNull"
or

"SELECT * FROM Files WHERE File_Num <> null"
0
 
SETPAuthor Commented:
Wow, RonaldBiemans, I can see why you're number one on the Top 15! Thanks...

PS. SELECT * FROM Files WHERE File_Num = '%' didn't work, but
      SELECT * FROM Files WHERE File_Num LIKE % did....
0
 
RonaldBiemansCommented:
Nice that it worked but Dhaest gave the same answer and was microseconds faster than me so he should have been awarded  the points :-)
0
 
DhaestCommented:
Thanks for your latest comment "RonaldBiemans"
0
 
SETPAuthor Commented:
Oops!!! Sorry, I honestly didn't see it! I'm terribly sorry Dhaest. Does anybody know how I can go about reversing the points?

I'm really sorry for this inconvenience! My bad!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.