473,395 Members | 1,658 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.

SQL code works correctly in access, but not from a C# program

Hello!

i have an sql query that works well (returns correct results) when used
in access XP, but does not work from a program... other queries work as
designed.

the query is:

SELECT P.ID, P.Sex, P.First, P.Last, P.CPhone, P.Phone, max(V.PDate) AS
LastVisited
FROM Partyers AS P LEFT JOIN VisitedParties AS V ON P.ID=V.PartyerID
WHERE P.PartyCities LIKE '*SOMECITY*'
GROUP BY P.ID, P.Sex, P.First, P.Last, P.CPhone, P.Phone;

and can also be found at http://pastebin.com/114283

will provide any other info if it is asked for... thanks in advance!

Best Regards,
Kosta.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
3 1120
Kosta,

Can you indicate what you are getting that is not correct? Also, can
you show how you are accessing it in .NET?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<kosta> wrote in message news:O$**************@TK2MSFTNGP12.phx.gbl...
Hello!

i have an sql query that works well (returns correct results) when used
in access XP, but does not work from a program... other queries work as
designed.

the query is:

SELECT P.ID, P.Sex, P.First, P.Last, P.CPhone, P.Phone, max(V.PDate) AS
LastVisited
FROM Partyers AS P LEFT JOIN VisitedParties AS V ON P.ID=V.PartyerID
WHERE P.PartyCities LIKE '*SOMECITY*'
GROUP BY P.ID, P.Sex, P.First, P.Last, P.CPhone, P.Phone;

and can also be found at http://pastebin.com/114283

will provide any other info if it is asked for... thanks in advance!

Best Regards,
Kosta.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
<kosta> wrote in message news:O$**************@TK2MSFTNGP12.phx.gbl...
WHERE P.PartyCities LIKE '*SOMECITY*'


Access recognizes "*" as a wildcard character in LIKE statements.

Every other form of SQL database (include ODBC & OLEDB) uses "%"
instead.
WHERE P.PartyCities LIKE '%SOMECITY%'

--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Nov 16 '05 #3
hello!
first of all, thanks for the responses.
when i say it works wrong, i mean that it returns an empty table...
this is how I run the query:

public static DataSet DSet(String sql)
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString =
ConfigurationSettings.AppSettings["conString"];
OleDbCommand cmd = new OleDbCommand(sql,con);
OleDbDataAdapter adp = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
return ds;
}

as you can see, the database is access based, so i think i need the *
wildcard... however, ill try and use the % notation...
also note that when i have LIKE "SOMECITY", i get what i should get
(people who only go to that one city) and if i have LIKE "*", i also get
what I should, which is everyone...

Best Regards,
Kosta.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Adrian B. | last post by:
Does anyone know of a framework or library that will enable me to use publish/subscribe comms? I want to create a server (using Python) running on a Unix box that will accept client connections...
242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
45
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
15
by: Shmuel (Seymour J.) Metz | last post by:
Back in the innocent days of the last century, I would have used a mailto link in my web page to allow people to cancel me. In the era of mass harvesting of addresses by spammers and other...
1
by: LenS | last post by:
If this is the wrong place to post this, please advise better place. Otherwise, I have created the following python program and it works. Running on XP. I think I am now at that stage of learning...
239
by: Eigenvector | last post by:
My question is more generic, but it involves what I consider ANSI standard C and portability. I happen to be a system admin for multiple platforms and as such a lot of the applications that my...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
27
by: George2 | last post by:
Hello everyone, Should I delete memory pointed by pointer a if there is bad_alloc when allocating memory in memory pointed by pointer b? I am not sure whether there will be memory leak if I do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.