Solved

SQL statement in VB

Posted on 2002-06-05
7
284 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 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