Board index » cppbuilder » How to do filtering

How to do filtering


2006-09-20 07:06:51 AM
cppbuilder15
Hi,
Here's part of my code:
line 1. ADOQuery1->SQL->Text = "select x1,x2 from table1";
line 2. ADOQuery1->Filtered = true;
line 3. ADOQuery1->Filter = "Production";
line 4. ADOQuery1->Active = true;
At line 4, I get the error below:
"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."
Production is a bit field in table1 of a SQL database. Any help for solving this is greatly appreciated.
Thanks,
Khai
 
 

Re:How to do filtering

Hi Khai,
Quote
Here's part of my code:
line 1. ADOQuery1->SQL->Text = "select x1,x2 from table1";
line 2. ADOQuery1->Filtered = true;
line 3. ADOQuery1->Filter = "Production";
line 4. ADOQuery1->Active = true;
Change it as follows:
ADOQuery1->SQL->Text = "select x1,x2 from table1";
ADOQuery1->Active = true;
ADOQuery1->Filter = "Production = 1"; // for example
ADOQuery1->Filtered = true;
Quote
At line 4, I get the error below:
"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."
It's about the filter expression - it's not an expression.
Quote
Thanks,
Khai
Groetjes,
Bob Swart
--
Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi
Blog: www.drbob42.com/blog - RSS: drbob42.com/weblog.xml
New Delphi 2006 Courseware e-books at www.eBob42.com/courseware
 

Re:How to do filtering

In addition, if you filter using column Production, it should be in select,
i.e. x1 or x2 should be Production.
//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Khai Trinh" < XXXX@XXXXX.COM >сообщи?сообщила ?новостях следующе?
Quote

Hi,

Here's part of my code:
line 1. ADOQuery1->SQL->Text = "select x1,x2 from table1";
line 2. ADOQuery1->Filtered = true;
line 3. ADOQuery1->Filter = "Production";
line 4. ADOQuery1->Active = true;

At line 4, I get the error below:
"Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another."

Production is a bit field in table1 of a SQL database. Any help for
solving this is greatly appreciated.

Thanks,
Khai
 

{smallsort}

Re:How to do filtering

Thank you Bob and Viatcheslav for your help, it did the job!
My program is also using the BDE TQuery in codes like below:
//Insert record to first table;
Query1->Active = false;
Query1->ParamByName("MISSILE_SN")->AsString = MslName;
Query1->Active = true;
Query1->Insert();
Query1->FieldByName("MISSILE_SN")->AssignValue(MslName);
Query1->FieldByName("USER_NAME")->AssignValue(UserName);
Query1->Post();
// Insert record to second table
Query2->Active = false;
Query2->ParamByName("MISSILE_SN")->AsString = MslName;
Query2->Active = true;
Query2->Insert();
Query2->FieldByName("MISSILE_SN")->AssignValue(MslName);
Query2->FieldByName("SERIALNO")->AssignValue(sn);
Query2->FieldByName("CSF_DATE")->AssignValue(testdate);
Query2->Post();
// Insert record to third table
Query3->Active = false;
Query3->ParamByName("MISSILE_SN")->AsString = MslName;
Query3->Active = true;
Query3->Insert();
Query3->FieldByName("MISSILE_SN")->AssignValue(MslName);
Query3->FieldByName("POSITION")->Value = i;
Query3->Post();
DisplayStatus("Apply initial updates");
TDBDataSet *Tables[3];
Tables[0] = Query1;
Tables[1] = Query2;
Tables[2] = Query3;
Query1->Database->ApplyUpdates(Tables,2);
The last line in this code is the one that actually applies the
updates to the three tables at once and roll everything back if
something goes wrong. I need to replace the TQuery controls
with ADOQuery controls. How can I do this?
I could do something similar to this below:
//Insert record to first table;
ADOQuery1->Active = false;
ADOQuery1->ParamByName("MISSILE_SN")->AsString = MslName;
ADOQuery1->Active = true;
ADOQuery1->Insert();
ADOQuery1->FieldByName("MISSILE_SN")->AssignValue(MslName);
ADOQuery1->FieldByName("USER_NAME")->AssignValue(UserName);
ADOQuery1->Post();
// Insert record to second table
ADOQuery2->Active = false;
ADOQuery2->ParamByName("MISSILE_SN")->AsString = MslName;
ADOQuery2->Active = true;
ADOQuery2->Insert();
ADOQuery2->FieldByName("MISSILE_SN")->AssignValue(MslName);
ADOQuery2->FieldByName("SERIALNO")->AssignValue(sn);
ADOQuery2->FieldByName("CSF_DATE")->AssignValue(testdate);
ADOQuery2->Post();
// Insert record to third table
ADOQuery3->Active = false;
ADOQuery3->ParamByName("MISSILE_SN")->AsString = MslName;
ADOQuery3->Active = true;
ADOQuery3->Insert();
ADOQuery3->FieldByName("MISSILE_SN")->AssignValue(MslName);
ADOQuery3->FieldByName("POSITION")->Value = i;
ADOQuery3->Post();
DisplayStatus("Apply initial updates");
//TDBDataSet *Tables[3];
//Tables[0] = Query1;
//Tables[1] = Query2;
//Tables[2] = Query3;
//Query1->Database->ApplyUpdates(Tables,2);
But this would update each table one at a time which is not what
I really want.
Thanks again,
Khai
"Viatcheslav V. Vassiliev" < XXXX@XXXXX.COM >wrote:
Quote
In addition, if you filter using column Production, it should be in select,
i.e. x1 or x2 should be Production.

//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)


"Khai Trinh" < XXXX@XXXXX.COM >сообщи?сообщила ?новостях следующе?
news:4510780b$ XXXX@XXXXX.COM ...
>
>Hi,
>
>Here's part of my code:
>line 1. ADOQuery1->SQL->Text = "select x1,x2 from table1";
>line 2. ADOQuery1->Filtered = true;
>line 3. ADOQuery1->Filter = "Production";
>line 4. ADOQuery1->Active = true;
>
>At line 4, I get the error below:
>"Arguments are of the wrong type, are out of acceptable range, or are in
>conflict with one another."
>
>Production is a bit field in table1 of a SQL database. Any help for
>solving this is greatly appreciated.
>
>Thanks,
>Khai