🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #369

Re: How to do filtering

#369
From: Khai Trinh
Date: Wed, 20 Sep 2006 15:49
122 lines
4844 bytes
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" <support@oledbdirect.com> wrote:
>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.
>http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
>ADO.Net
>http://www.oledbdirect.com - The fastest way to access MS SQL Server,
>MS Jet (Access) and Interbase (through OLEDB)
>
>
>"Khai Trinh" <khai.trinh1@navy.mil> �������/�������� � �������� ���������: 
>news:4510780b$1@newsgroups.borland.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 
>
>
Technical Details
Message-ID: <45116306$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4510780b$1@newsgroups.borland.com> <4510ec6d$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,268b4c7dd301faa8
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Khai Trinh" <khai.trinh1@navy.mil>
Sender: "Khai Trinh" <khai.trinh1@navy.mil>
Reply-To: "Khai Trinh" <khai.trinh1@navy.mil>
Subject: Re: How to do filtering
Newsgroups: borland.public.cppbuilder.database.ado
X-User-Info: 138.163.0.44     
References: <4510780b$1@newsgroups.borland.com> <4510ec6d$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <45116306$1@newsgroups.borland.com>
Date: 20 Sep 2006 08:49:26 -0700
X-Trace: newsgroups.borland.com 1158767366 207.105.83.66 (20 Sep 2006 08:49:26 -0700)
Lines: 123
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail