How to filter database recordsets?

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

How to filter database recordsets?

Postby melaosX » Tue Feb 22, 2005 4:18 am

1. Hi, i'm a total newbie with c++ builder 6 here, and currently i need to build a application which would show the total booking of a cruise ship according to the package number and another form to show the total booking with the specified date.

So i was wondering how to i setup a drop down box[let's say months;jan,feb,mac] on one form and then sent the month to update the query on another form as to show this.

Now i already know how to retrieve data with form wizard, tquery and how to update,insert n delete with tupdatesql. But i'm clueless on how to perform the above.
2. Plus how do i setup a form to be linked to another form either through a button or any other means?
Any advice would be more than helpful.

Thanks in advance!! :?:
melaosX
 

Date Combo Box

Postby 2ffat » Tue Feb 22, 2005 4:00 pm

The date is easy, BCB has TComboBox that will work just fine. I use it a lot in apps like this. Once you drop it onto your for, you set up its TStrings for each month, Jan, Feb, etc.

When the person selects a specific month, the ComboBox will have its index set. You grab the index and from there you set up how you get the date from the DB, .e.g. Jan = 1 or Jan = January; however you have your data set up in the DB.
James P. Cottingham

Look at me still talking
when there is science to do.
User avatar
2ffat
Forum Mod
Forum Mod
 
Posts: 444
Joined: Wed Jun 23, 2004 7:07 am
Location: South Hill, VA

Reply

Postby melaos » Tue Feb 22, 2005 6:02 pm

But how do i passes the month within the tcombo to the recordset so the retrieved data will be in accordance with the month selected by the user?

Do i just set the property in some other VCL object? Or do i need to write some code?

Plus how do i setup a form to be linked to another form either through a button or any other means?

Any advice or link to related information would be more than helpful.

Thanks in advance!!
melaos
 

TDataSet

Postby 2ffat » Tue Feb 22, 2005 6:43 pm

You can use a TDataSet to do most of the thing you want to do. How you do this depends on how yor data base is set up. If you have a key (index) set up, you can use that. Otherwise, you mayhave to filter the data.

You can put the code in a button's event. Look at the TDataSet help file, then post here for more details.
James P. Cottingham

Look at me still talking
when there is science to do.
User avatar
2ffat
Forum Mod
Forum Mod
 
Posts: 444
Joined: Wed Jun 23, 2004 7:07 am
Location: South Hill, VA


Return to Technical

Who is online

Users browsing this forum: Google [Bot] and 18 guests