Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 649
  • 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)
Tables
(T_COMPANY  fields: C_CODE, C_COMPANY)
(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->PobQuery1->Close();
 PobMod->PobQuery1C_CODE->AsString = Edit1->Text;
 PobMod->PobQuery1->Open();
}
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?
0
Pedraz
Asked:
Pedraz
1 Solution
 
kode99Commented:
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;
PobMod->PobQuery1->Open();

Then to edit,

PobMod->PobQuery1->Edit();
PobMod->PobQuery1C_CODE->AsString = Edit1->Text;
PobMod->PobQuery1->Post();

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.

0
 
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.
0
 
bansidharCommented:
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.

bansidhar
Experts Exchange Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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