Solved

SQL statement in VB

Posted on 2002-06-05
7
282 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now