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

  • Thread starter Thread starter kosta
  • Start date Start date
K

kosta

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.
 
Kosta,

Can you indicate what you are getting that is not correct? Also, can
you show how you are accessing it in .NET?
 
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.
 
Back
Top