![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2006
Posts: 10
Rep Power: 0
![]() |
Using Sql and BDE
I would like to know how do i use a simple sql statement to to select data from the contents of 1 edit box to another edit box?
For example I have a database called query and i would like to filter dates on the table, but i want the sql statement to look in edit 1 box what is the start date and then in edit 2 box what is the end date, and then filter it. Here is an example of my code wich dosent work: SELECT * FROM Query WHERE QOUTEDATE >= :edit1 AND QOUTEDATE <= :edit2 AND RepName = :edit3 Thank You Werner |
|
|
|
|
|
#2 |
|
Newbie
|
Well you can try this, I couldn't figure it out myself but i went and asked around, Try this :
procedure TForm14.Button17Click(Sender: TObject); begin Query1.Close; Query1.SQL.Clear; Query1.SQL.Add('SELECT * FROM Query WHERE QOUTEDATE BETWEEN ' + edit1.Text + ' AND ' + edit2.Text + ' AND RepName = ' + edit3.Text); Query1.Open; end; However there could be a problem with this if the database server does not recognize the date format from the edit boxes. In this case the workaround could be: procedure TForm14.Button17Click(Sender: TObject); begin Query1.Close; Query1.ParamByName('qoutedate1').AsDateTime := StrToDateTime(edit1.Text); Query1.ParamByName('qoutedate2').AsDateTime := StrToDateTime(edit2.Text); Query1.ParamByName('repname').AsString := edit3.Text; Query1.Prepare(); query1.Open; end;
__________________
Forgive me if I ask Stupid Questions, to you it may be stupid but to me it's something I want to find out! So Please bear with me and help me out! Thank you! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|