473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how does LIKE operator work?

24
I want to write sql sentence with LIKE operator. I wrote this code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command8_Click()
  2. List1.Clear
  3. Set db = OpenDatabase("the path of my database")
  4. Set rec = db.OpenRecordset("SELECT * From asmenu_info WHERE asmenu_info.pavarde LIKE '%Pet%';")
  5. While Not rec.EOF
  6. List1.AddItem rec!ID & "  " & rec!Vardas & "   " & rec!pavarde & "  " & rec!Data
  7. rec.MoveNext
  8. Wend
  9. rec.Close
  10. db.Close
  11. End Sub
and my program does nothing. I don't undestand how does LIKE work?
Apr 29 '07 #1
3 2724
markmcgookin
648 Expert 512MB
I want to write sql sentence with LIKE operator. I wrote this code:

Private Sub Command8_Click()
List1.Clear
Set db = OpenDatabase("the path of my database")
Set rec = db.OpenRecordset("SELECT * From asmenu_info WHERE asmenu_info.pavarde LIKE '%Pet%';")
While Not rec.EOF
List1.AddItem rec!ID & " " & rec!Vardas & " " & rec!pavarde & " " & rec!Data
rec.MoveNext
Wend
rec.Close
db.Close
End Sub

and my program does nothing. I don't undestand how does LIKE work?

Hi,

I developed a VB app in the compact framework for a PDA and using SQL Sever CE and not MS access, but when I was doing something like this, I used this format:

I am assuming that you have assigned "Pet" as a string variable or something

i.e.
Expand|Select|Wrap|Line Numbers
  1. Dim Pet As String
  2. Pet = "Dog"
  3.  
  4. etc...
  5.  
  6. Set rec = db.OpenRecordset("SELECT * From asmenu_info WHERE asmenu_info.pavarde LIKE ' " & Pet & " ' ")
  7.  
But I am not sure if that would be the same for an Access DB
Apr 29 '07 #2
Eglute
24
I didn't assign Pet as a variable because I think that it is only a string line I want to find in my database. Why need I to assign Pet as a variable? When I wrote this code in Access I wrote:

Set rec = db.OpenRecordset("SELECT * From asmenu_info WHERE asmenu_info.pavarde LIKE "*Pet*"; ")

and the querry was good, but with visual basic it doesn't work. I don't understand why?
Apr 29 '07 #3
Killer42
8,435 Expert 8TB
I didn't assign Pet as a variable because I think that it is only a string line I want to find in my database. Why need I to assign Pet as a variable? When I wrote this code in Access I wrote:

Set rec = db.OpenRecordset("SELECT * From asmenu_info WHERE asmenu_info.pavarde LIKE "*Pet*"; ")

and the querry was good, but with visual basic it doesn't work. I don't understand why?
Actually, I think you have the Like clause correct. It should work exactly the same from VB as when used directly in Access. However, I note that in your original post you have converted the asterisks to percent symbols. If you are still talking to an Access database, I believe you still need to use the asterisks.
Apr 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Roy Yao | last post by:
Why the following code let my compiler complain an overloaded function Init()? // code begin template<class T> class BicircularList { template<class T> class Iterator; template<class T> class...
18
by: Joe Seigh | last post by:
Is there a good write on this. The textbooks I have fluff over on this? Specifically, I trying to dereference with 2 levels of type conversion not 1, i.e. X<T> -> z => Y<T> -> z => T* ->...
8
by: Douglas | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** Hello, The following code does not compile if line 3 is uncommented "using namespace std". I do not understand it. Could...
4
by: PKH | last post by:
This is a part of an autopointer template i'm using. I originally had a Get() member that returned the pointer, but thought it would nice to be able to use the -> operator. The question is why...
3
by: Zheng Da | last post by:
Will the following class work well? If it can not work correctly in some situation, could you help me to fix it? Thank you. //the class will work like the reference in java //when you create a...
6
by: YUY0x7 | last post by:
Hi, I am having a bit of trouble with a specialization of operator<<. Here goes: class MyStream { }; template <typename T> MyStream& operator<<(MyStream& lhs, T const &)
2
by: Steven T. Hatton | last post by:
I'm still not completely sure what's going on with C++ I/O regarding the extractors and inserters. The following document seems a bit inconsistent:...
18
by: Daniel Billingsley | last post by:
Or seem to anyway. ===== string abc; if ((abc=getString()) != "") { MessageBox.Show(abc); } private string getString() {
4
by: Tony Johansson | last post by:
Hello!! I have done some operator overloading but my main testprogram doesn't work well. Have you any idea which of my methods are wrong? #include <iostream> #include <string> using...
10
by: Pavel Shved | last post by:
Is there a program of wide use that automatically extracts template parameters requirements from source code of template functions? I mean the following: assume we have a template function that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.