C++Builder 5.02 / Windows XP stucked around a query

Posted on 2007-07-22
Last Modified: 2013-11-24
C++Builder 5.02 / Windows XP
TMS Software (DBAdvGrid) to display a query (PobMod->PobQuery1)
(T_EMPLOYEE fields: C_CODE, E_ID, E_NAME,........................)
(T_ROOM fields C_CODE, E_ID, R_ROOM,.....)
The query is sorted by (SQL ->   ".....ORDER BY T_company.C_CODE, T_employee)
I have a boolean field to indicate if the person is on board or if he is at home
The grid, just now displays all the results and another information like the row number and the record number
The results for the query related to the persons on board are not more than 115 (that is the  total capacity of this ship) In the other hand the people moving around could be up to 300
As you can see it is not a big deal
I am using Borland Visual dBase 7.5 to create the tables and the query
I am looking how to filter the query result to display on the grid the following
1.- All the results
2.- The results filtered by the field C_CODE and/or C_COMPANY. So the user has the option to see only the personnel for a  company at a time in the dbgrid
Only for personnel on board, so the field E_ONBOARD is checked (true)
3.- All the results when E_ONBOARD is unchecked
4.- The above filtered by C_CODE or C_COMPANY
This is my first project on C++Builder and I am trying to create an application for a personal use and solve a lot of paperwork now keep it in another lot of folders created around the PC
Thanks to Kode99 I was able to go a step forward and I found another problem

My code is
void_fastcall TForm1::Button1Click(TObject *Sender)
 PobMod->PobQuery1C_CODE->AsString = Edit1->Text;
The result is
" Project Project1.exe raised exception class EDatabaseError with message 'PobQuery1: Dataset not in edit or insert mode'. Process stopped. Use Step or Run to continue"
Well before I couldn't get anything, this one doesn't look so bad.
How to keep the dataset in edit or insert mode?
Question by:Pedraz
    LVL 25

    Accepted Solution

    You may have a problem here as I believe your query draws from multiple tables.  If this is the case your returned dataset is read only so you cannot edit it.  This is not a big problem but does mean you will need to access the record through a alternate query or table and then refresh the data in the first one.

    If the data set is from only a single table you can open the query with the 'RequestLive' property set to true.  This will allow you to edit the data set.

    So open the request with the RequestLive,

    PobMod->PobQuery1->RequestLive = true;

    Then to edit,

    PobMod->PobQuery1C_CODE->AsString = Edit1->Text;

    Edit() puts a dataset into write mode and the Post() write the change and turn write mode off.  This is the same style that would be used with a TTable as well.

    So if your original query is read only you could either use a TTable or another TQuery - but only draw the results from the one table.  The above Edit/Post will work.

    If you need to search for the record to edit within a data set you can search on an index using FindKey.    

    The Borland help for all these properties and methods is useful.

    LVL 16

    Expert Comment

    by:George Tokas
    One addition:
    After the post it will be better to call Close() so all transactions to finish...
    Having open queries leads to mistakes not easy to be handled...

    George Tokas.
    LVL 11

    Expert Comment

    No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

    I will leave the following recommendation for this question in the Cleanup Zone:
    Accept [kode99]'s comment as answer

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    Experts Exchange Cleanup Volunteer

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    A short article about a problem I had getting the GPS LocationListener working.
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now