Solved

SQL statement in VB

Posted on 2002-06-05
7
286 Views
Last Modified: 2010-05-02
Hello,
I've written the following SQL statement:

SELECT Students.*
FROM Students
WHERE (Student_ID LIKE '1*')

It works in a query in MS-Access, but when I use THE SAME statment in VB (I use Data-Environment) it doesn't work. Why??

I have tried to use "[Student_ID]" instead of "Student_ID", "*" instead of "Students.*" etc... Nothing helped.

Any ideas?

P.S.  I will increase points if I get an answer shortly!!!
0
Comment
Question by:slavikn
7 Comments
 
LVL 4

Accepted Solution

by:
frankd earned 115 total points
ID: 7056970
I would try this:

WHERE (Student_ID LIKE '1%')


I've always used % for the wildcard in SQL

Hope this helps

Frank
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7057162
frankd is correct.  Access is a strange beast that tries to use the Microsoft standards internally (where "*" is a wildcard) but uses the SQL standard externally (where "%" is a wildcard.)
0
 
LVL 1

Expert Comment

by:toys032498
ID: 7057273


Also what your datatypes.
If STUDENT_ID is an int

Then
WHERE (convert(varchar(10), Student_ID) LIKE '1%')
OR
WHERE (Student_ID > 1)
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
LVL 1

Author Comment

by:slavikn
ID: 7057351
toys, I the field is of String type. Anyway, I've already got the answer...
0
 
LVL 1

Author Comment

by:slavikn
ID: 7057356
Thank you very much! This really helped. I also increased the point to 115 (instead of 100) as I'd promised. I simply need them for future questions.
0
 
LVL 1

Author Comment

by:slavikn
ID: 7057573
0
 
LVL 4

Expert Comment

by:frankd
ID: 7058010
slavikn,

Thanks for the points, I'm glad I was able to help.

Frank
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

830 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