473,804 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how does LIKE operator work?

24 New Member
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 2739
markmcgookin
648 Recognized Expert Contributor
I want to write sql sentence with LIKE operator. I wrote this code:

Private Sub Command8_Click( )
List1.Clear
Set db = OpenDatabase("t he path of my database")
Set rec = db.OpenRecordse t("SELECT * From asmenu_info WHERE asmenu_info.pav arde 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 New Member
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.OpenRecordse t("SELECT * From asmenu_info WHERE asmenu_info.pav arde 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 Recognized Expert Expert
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.OpenRecordse t("SELECT * From asmenu_info WHERE asmenu_info.pav arde 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
3207
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 ChainNode { friend Iterator<T>;
18
9726
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* -> z and *X<T> => *Y<T> => *T The Y<T> conversion has to be done as an expression temp. It cannot be done
8
4378
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 somebody explain it to me? I am using MSVC 6.0. Thanks a lot,
4
1781
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 does the following line work, and call cAP.m_pcPointer->Testing() ? cAP->Testing(); // ??? cAP-> returns a CTest*, so it looks to me like the line reads cAP.m_pcPointer <whitespace> Testing(), but it actually does
3
1457
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 object, you must save the pointer of the object in super_auto_ptr //the class cannot work correctly in multithread
6
4431
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
3511
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: http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#1 Copying a file: WRONG WAY: #include <fstream> std::ifstream IN ("input_file"); std::ofstream OUT ("output_file");
18
2276
by: Daniel Billingsley | last post by:
Or seem to anyway. ===== string abc; if ((abc=getString()) != "") { MessageBox.Show(abc); } private string getString() {
4
1760
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 namespace std;
10
2101
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 demands its template parameter(s) to meet certain requirements. For example simple sorting function template <typename Tvoid sort(T* t, int N) { for (int i=0;i<N-1; i++)
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.