Page 1 of 1

Help with SYntax

Posted: Thu 12 Jan 2006 14:11
by classicmydac
Upgraded from Paradox tables to MYSQL but the following statement does not bring any results back.

How do I resove this please.

Steve W




franchisee :=edit5.Text;
if franchisee = '199' then temp := 'SELECT * FROM Tickets WHERE DATEDIFF(:today,First_Letter_Date) > 30 AND Ticket_Status = "1st DVLA request" ORDER BY Registration_No DESC ';

if franchisee = '199' then temp := 'SELECT * FROM Tickets WHERE Ticket_Status = "Completed" AND Paid_date BETWEEN :startdate1 AND :enddate1 ORDER BY Location_Code';

if franchisee '199' then temp := 'SELECT * FROM Tickets WHERE Belongs_Number = "'+franchisee+'" AND Ticket_Status = "Completed" AND Paid_date BETWEEN :startdate1 AND :enddate1 ORDER BY Location_Code';
Query_Tickets.SQL.Text := temp;
Query_Tickets.ParamByName('startdate1').AsDatetime := DateTimePicker1.Date;
Query_Tickets.ParamByName('enddate1').AsDateTime := DateTimePicker2.Date;
Query_Tickets.Open;

Posted: Fri 13 Jan 2006 07:36
by Ikar
Please specify if there are any errors when you try to open Query_Tickets and check value of Active property after this. Set Query_Tickets.debug option to true just before your Query_Tickets is opened, and then run your application that opens Query_Tickets. Check your SQL statement and parameter values that will be shown in debug window and test it if necessary.

You typed three conditions. Be attentive: the first one and the second one are the same. Therefore your first query will never be executed!

Note: to use debug window don't forget to include MyDacVcl unit to uses list.