Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL statement in VB

Posted on 2002-06-05
7
Medium Priority
?
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Accepted Solution

by:
frankd earned 460 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

610 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