?
Solved

SELECT ALL

Posted on 2005-04-22
9
Medium Priority
?
235 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:SETP
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 13841883
"SELECT * FROM Files WHERE File_Num Like '%'"
0
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 2000 total points
ID: 13841884
Use it with the like operator


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

or maybe  just try

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




0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 13841893
change:

SELECT * FROM Files WHERE File_Num = %  

to:

SELECT * FROM Files WHERE File_Num like '%'

AW
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 13841897
too slow... just shows the great minds think alike LOL  ;-)

AW
0
 
LVL 35

Expert Comment

by:YZlat
ID: 13842210
"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
 

Author Comment

by:SETP
ID: 13842434
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
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 13842483
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
 
LVL 53

Expert Comment

by:Dhaest
ID: 13842669
Thanks for your latest comment "RonaldBiemans"
0
 

Author Comment

by:SETP
ID: 13847037
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question