• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

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

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?
1 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.

George TokasCommented:
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.
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now