Thread View: borland.public.cppbuilder.database.ado
5 messages
5 total messages
Started by Cenk
Fri, 04 Aug 2006 15:56
TADOQuery problem
Author: Cenk
Date: Fri, 04 Aug 2006 15:56
Date: Fri, 04 Aug 2006 15:56
23 lines
1539 bytes
1539 bytes
Hi,
I wanna use multiple select statements as below but it gives error, would
you please help?
sample code segment.
TADOQuery *CountQuery;
CountQuery= new TADOQuery (this);
CountQuery->Connection = ADOConnection1;
CountQuery->SQL->Add ("select COUNT(bid) from ["+table+"]");
CountQuery->Open ();
count = CountQuery->FieldByName ("COLUMN1")->AsInteger;
CountQuery->SQL->Clear(); --------> CAN NOT PERFORM THIS OPERATION ON AN
OPEN DATASET!
CountQuery->SQL->Add ("select [bid],[fTime] from ["+table+"] order by
[fTime] ASC");
CountQuery->Open ();
How can i use multiple TADOQuery?
Re: TADOQuery problem
Author: Viatcheslav V. Vassiliev
Date: Fri, 04 Aug 2006 16:12
Date: Fri, 04 Aug 2006 16:12
44 lines
2395 bytes
2395 bytes
Add
CountQuery->Close();
when you do not need this dataset open. Btw if in first dataset you want to
get count of records in second dataset, you will have wrong result - select
count(bid) returns count of rows where bid is not null.
//------------------------------------------
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)
"Cenk" <cenk1536@yahoo.com> �������/�������� � �������� ���������:
news:44d36e64@newsgroups.borland.com...
> Hi,
>
> I wanna use multiple select statements as below but it gives error, would
> you please help?
>
> sample code segment.
>
> TADOQuery *CountQuery;
> CountQuery= new TADOQuery (this);
> CountQuery->Connection = ADOConnection1;
>
> CountQuery->SQL->Add ("select COUNT(bid) from ["+table+"]");
> CountQuery->Open ();
> count = CountQuery->FieldByName ("COLUMN1")->AsInteger;
>
>
> CountQuery->SQL->Clear(); --------> CAN NOT PERFORM THIS OPERATION ON AN
> OPEN DATASET!
> CountQuery->SQL->Add ("select [bid],[fTime] from ["+table+"] order by
> [fTime] ASC");
> CountQuery->Open ();
>
> How can i use multiple TADOQuery?
>
>
Re: TADOQuery problem
Author: Cenk
Date: Fri, 04 Aug 2006 16:20
Date: Fri, 04 Aug 2006 16:20
40 lines
2142 bytes
2142 bytes
thanks for your warning but there is no NULL in table.
Now there is another error pops up!
TADOQuery *CountQuery;
CountQuery= new TADOQuery (this);
CountQuery->Connection = ADOConnection1;
CountQuery->SQL->Add ("select COUNT(bid) from ["+table+"]");
CountQuery->Open ();
count = CountQuery->FieldByName ("COLUMN1")->AsInteger;
CountQuery->SQL->Clear();
CountQuery->SQL->Add ("select [bid],[fTime] from ["+table+"] order by
[fTime] ASC");
CountQuery->Open ();
for (int i = 0;i<count ;i++)
{
v_bid.push_back(CountQuery->FieldByName ("bid")->AsFloat);
v_time.push_back(CountQuery->FieldByName ("fTime")->AsDateTime);
CountQuery->Next ();
}
start = v_time.at(0);
end = v_time.at(count-1);
CountQuery->Close(); -----> NOW IT GIVES ERROR HERE! ITS EITHER BOF
OR EOF OR THERE IS NO VALID RECORD
CountQuery->SQL->Clear();
CountQuery->SQL->Add ("SET DATEFORMAT dmy");
CountQuery->SQL->Add ("SELECT distinct DATEDIFF(n, '"+start+"',
'"+end+"') AS diff from ["+table+"]");
CountQuery->Open ();
Re: TADOQuery problem
Author: Cenk
Date: Fri, 04 Aug 2006 16:40
Date: Fri, 04 Aug 2006 16:40
18 lines
1453 bytes
1453 bytes
for (int i = 0;i<count ;i++)
{
v_bid.push_back(CountQuery->FieldByName ("bid")->AsFloat);
v_time.push_back(CountQuery->FieldByName ("fTime")->AsDateTime);
CountQuery->Next ();
}
start = v_time.at(0);
end = v_time.at(count-1);
CountQuery->Close(); -----> EOleException with message 'BOF or EOF
is truth or the first registry was deleted. The actual operation needs a
actual registry".
Re: TADOQuery problem
Author: Viatcheslav V. Vassiliev
Date: Sat, 05 Aug 2006 07:44
Date: Sat, 05 Aug 2006 07:44
42 lines
2244 bytes
2244 bytes
If you use C++ Builder 5, install ADO update.
Correct way to traverse dataset is:
CountQuery->First();
while (!CountQuery->Eof)
{
...
CountQuery->Next();
}
//------------------------------------------
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)
"Cenk" <cenk1536@yahoo.com> �������/�������� � �������� ���������:
news:44d37887@newsgroups.borland.com...
> for (int i = 0;i<count ;i++)
> {
>
> v_bid.push_back(CountQuery->FieldByName ("bid")->AsFloat);
>
> v_time.push_back(CountQuery->FieldByName ("fTime")->AsDateTime);
>
> CountQuery->Next ();
> }
>
> start = v_time.at(0);
>
> end = v_time.at(count-1);
>
>
> CountQuery->Close(); -----> EOleException with message 'BOF or EOF
> is truth or the first registry was deleted. The actual operation needs a
> actual registry".
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads