473,395 Members | 1,931 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,395 software developers and data experts.

Like clause

Hi

I have a windows application with an Access database where I execute the following:

cmd.CommandText = "SELECT Id FROM Users WHERE surname LIKE \"p*\"";

I'm trying to find all users who's surname starts with "P".

When I fill a dataset using the above no results are returned but when I take that exact string and run it directly in Access it returns the correct Id.

Any ideas why (or how if im doing it incorrecly) no data is being returned? The connection and everything else is fine because if I do a simple SELECT id FROM users it returns records.

I have promised myself to never use access as a database again as I have had countless problems thus far where an SQL Express database wouldnt have.

Thanks
Stefan
Nov 27 '07 #1
4 1324
Denburt
1,356 Expert 1GB
Try the following:

cmd.CommandText = "SELECT Id FROM Users WHERE surname LIKE 'p*'"

or

cmd.CommandText = "SELECT Id FROM Users WHERE surname LIKE ""p*"""
Nov 27 '07 #2
Hi Denburt

Thanks for the reply but the results are the same :(
Nov 28 '07 #3
Jim Doherty
897 Expert 512MB
Hi Denburt

Thanks for the reply but the results are the same :(
Hmm.. Stefan me thinks ansii

try the percent sign instead of asterisk

Jim
Nov 28 '07 #4
Hi Jim

Thanks for the quick response but I've opted to rather fill my grid with the entire recordset and then filter it programmatically with c# using a dataview.

Thanks.
Stefan
Nov 28 '07 #5

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

Similar topics

105
by: Peter Hickman | last post by:
Well after all this discussion it would appear that a 'Python like' language has appeared => Prothon. http://www.prothon.org/index.html Very alpha, sort of like Python (if you consider the...
4
by: Tom Walker | last post by:
I cannot get the WHERE statement to work correctly unless I use a literal with the LIKE. I want to use a working storage data name so that I can vary the WHERE statement. Example that works: ...
1
by: Kerr | last post by:
Hi all, I am writing a simple app to query a microsoft access 2000 databse in asp.net. Nothing complicated, but I am writing some inline SQL to query a table with a LIKE clause in it (i.e....
2
by: Michael C | last post by:
Hi all. When I run the following query against my Access database - from within Access - it returns the correct results (5 records in this instance): SELECT * FROM WHERE = "Clothes" AND LIKE...
26
by: GreatAlterEgo | last post by:
Hi, This is my query which is embedded in a COBOL program. EXEC SQL SELECT DATE, AGE, DURATION, AMT INTO :LDATE, :L.AGE, :L.DURATION, :L.AMT FROM TAB1 WHERE CODE = :KEY.CODE AND...
7
by: Mike Charney | last post by:
Can anyone tell me why the following statement doesnt work? DoCmd.OpenForm "frmSearchResults", , , "text24 Like *" & filter1 & "*" Field text24 is the field on teh results form that I am trying...
5
by: davehansen22 | last post by:
Is there a way to generate a MySQL WHERE clause from a search string like this: "(dave OR hansen) php programmer" I would want to use the generated MySQL clause against a "memo" type field. ...
5
by: pwiegers | last post by:
Hi, I'm trying to use the result of a conditional statement in a where clause, but i'm getting 1)nowhere 2) desperate :-) The query is simple: -------- SELECT idUser,...
1
by: john | last post by:
I'm trying to build a LINQ expression that will use a dynamic construction of a LIKE statement in the WHERE clause, it would look something like this in SQL: WHERE TaskGroup Like "*00*" OR...
5
by: nidaar | last post by:
From a security point of view, is accepting wildcards like "%" in input parameters of stored procedures against any best practices? As an example, if a user defined function uses "Productname...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.