Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2001, 06:47 AM
Excalibur Excalibur is offline
Junior Member
 
Join Date: Jan 2001
Posts: 16
Default Query Problem......( Help, Help )

I am making a query where I most find a date but i dont know how to pass the date.... this is the code

FModule.Q1.SQL.Add('SELECT DISTINCT Table.date');
FModule.Q1.SQL.Add('WHERE table.date =');
FModule.Q1.SQL.Add(Combo.SelText);<--this is the problem
FModulo.Q1.Open;

The date on the table is a datetime field, and when i make the query I dont have any answer, and I most pass the information as string..... what can i do in order to the query works correctly.... Help, Help,.....thanks a lot..
Reply With Quote
  #2  
Old 01-18-2001, 06:51 AM
PoseFant PoseFant is offline
Senior Member
 
Join Date: Jan 2001
Posts: 1,002
Default RE: Query Problem......( Help, Help )

Without trying it myselfe I suppose that this will work ...

SQL.Add('SELECT DISTINCT FROM Table.date WHERE Table.date=' + Combo.Text);


Regards

/Filip
Reply With Quote
  #3  
Old 01-18-2001, 06:54 AM
PoseFant PoseFant is offline
Senior Member
 
Join Date: Jan 2001
Posts: 1,002
Default RE: RE: Query Problem......( Help, Help )

woops ... Forgot StrToDate(Combo.Text)


Kinda stressed ... ;o)

/Filip
Reply With Quote
  #4  
Old 01-18-2001, 07:26 AM
pascal.enz pascal.enz is offline
Member
 
Join Date: Jan 2001
Posts: 73
Default RE: RE: RE: Query Problem......( Help, Help )

Try to convert the date to the US date format MM/DD/YYYY. Some database drivers can't read the international or local date and time formats.

Good luck
Reply With Quote
  #5  
Old 01-18-2001, 08:06 AM
Excalibur Excalibur is offline
Junior Member
 
Join Date: Jan 2001
Posts: 16
Default RE: RE: RE: RE: Query Problem......( Help, Help )

Thaks a lot my friends .....but I have the answer now...

i cant conver the string to date because to add the SQL I need a string...... In fact the correct form is to put #
example

MOdule.Q1.sql.addŽ('where table.date='+'#'+combo.text+'#')

thats the form...... I saw the query in access and it have that form...and it is working.
Reply With Quote
  #6  
Old 01-18-2001, 06:44 PM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default RE: Query Problem......( Help, Help )

the answere found by you will work though it will slow down the database server

so the better option will be to use the bind variable in query and then assign the value to it on combobbox.change

like

your can write the query as

query.sql.text := 'Select disctinct tableDate from table where tableDate = :dt';



now on query's before open even you can write the following


query1.parambyname('dt').value := combobox1.text;




now you dont have do do anything else plus there is added advantage because if you are opening the same query again and again then your database need not parse the query string again and again as it remains constant with the result of faster response from it
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 10:51 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.