Page 1 of 1

TZQuery problem Delphi 6

Posted: 25.10.2006, 08:20
by ejla
I'm working with Delphi 6 with 6.5.1. alpha CSV.
A query below don't return right data from MySQL 4.1 database.
The resultset is filtered ONLY by date, but all arrivals with respective arrival date will be in the resultset.
What mad?
code:
[font=Courier New]query := 'select * from booking where b_date = "' +
edArrDate.Text + '"' +
' and arrTime = "' + edArrTime.Text +'"' ;[/font]


sql1.Sql.Clear;
Sql1.Sql.Add(query);
sql1.Open ;

TZquery and dates in MySQL.

Posted: 25.10.2006, 09:45
by BigLuis
I dont know exactly the answer but try to use parameters like "SELECT * from table where date_field=:dDate and time_field=:tTime;
var
myDate:Tdate;
myTime:TTime;
myDate:=strtodate(edit1.text).
query.parambyname('ddate').asdatetime:=myDate;
Anyway I think you have to pass the date in the correct format when you do it directly from a text box "YYYY/MM/DD" because when you pass the date like a variable i think Delphi format it aumaticly.
If I program like a write I shall never finish a program.......

Posted: 25.10.2006, 10:20
by mdaems
Hi Ejla,

Did you check the resulting 'query' variable and pasted that query in the mysql console to check the result? Maybe the format of date and time are not exactly as mysql expects them.
Also, you may drop a ZSQLMonitor component in your project and use it to log the actual queries sent to the server to a flat file. That result must give the right result in mysql console.

Let us know how you do.
(And try the beta version, it already had some fixes after 2005)

Mark

Posted: 25.10.2006, 10:43
by ejla
Hi and thanks,
well I see that its problem with something else but query... :oops:
I'm usin editable TDBGrid and its source is TZTable (called ResultSet...) The MasterSource for the TZTable is dsSQL1 (from TZQuery).
TZQuery seems work OK, but someting between TZQuery & TZTable.

Posted: 25.10.2006, 15:10
by ejla
ejla wrote:Hi and thanks,
well I see that its problem with something else but query... :oops:
I'm usin editable TDBGrid and its source is TZTable (called ResultSet...) The MasterSource for the TZTable is dsSQL1 (from TZQuery).
TZQuery seems work OK, but someting between TZQuery & TZTable.
All OK again... I take away TZTable and use TZQuery's updateSQL instead. Everything work fine and much more faster than B4.