🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
2 messages
2 total messages Started by Danid Wed, 15 Jun 2005 16:47
Cannot perform this operation on closed dataset
#841
Author: Danid
Date: Wed, 15 Jun 2005 16:47
37 lines
1526 bytes
Please help,

I have the following function:

TADOQuery *TCon :: select(String SQL)
{
  //qryData is a TADOQuery 
  try{
   qryData->SQL->Clear();
   qryData->SQL->Add(SQL);
   qryData->SQL->Open();
  } catch (EXception &e) {
   //
  }
  return qryData;
}

call this function in other classes:

TADOQuery *qry = new TADOQuery(Application);
TCon *con = new TCon(Application);

String SQL = "SELECT * FROM TABLE WHERE A = B"; //example
qry = con->select(SQL);
//do something with qry 

delete qry;
delete con;

This code works fine excepts that it sometimes rises the following error:
Cannot perform this operation on closed dataset

How can I solve this?
I looked on the internet but couldnt find a solution.

Thanks,
Re: Cannot perform this operation on closed dataset
#845
Author: Michele Santucci
Date: Thu, 16 Jun 2005 08:25
64 lines
2526 bytes
    I don't know if TADOConnection and TADOQuery objects are always 
connected / activated after
    they creation so you may try to do so by yourself:

        TADOConnection *con = new TCon(Application);
        TADOQuery *qry = new TADOQuery(Application);

        con->Connected = true;
        ^^^^^^^^^^^^^^^^^^

        String SQL = "SELECT * FROM TABLE WHERE A = B"; //example
        qry = con->select(SQL);

        qry->Active = true;
        ^^^^^^^^^^^^^^^

        //do something with qry

        delete qry;
        delete con;

    Hope this help... by[t]e(s)

"Danid" <danid@danid.com> ha scritto nel messaggio 
news:42b05bb3$1@newsgroups.borland.com...
>
> Please help,
>
> I have the following function:
>
> TADOQuery *TCon :: select(String SQL)
> {
>  //qryData is a TADOQuery
>  try{
>   qryData->SQL->Clear();
>   qryData->SQL->Add(SQL);
>   qryData->SQL->Open();
>  } catch (EXception &e) {
>   //
>  }
>  return qryData;
> }
>
> call this function in other classes:
>
> TADOQuery *qry = new TADOQuery(Application);
> TCon *con = new TCon(Application);
>
> String SQL = "SELECT * FROM TABLE WHERE A = B"; //example
> qry = con->select(SQL);
> //do something with qry
>
> delete qry;
> delete con;
>
> This code works fine excepts that it sometimes rises the following error:
> Cannot perform this operation on closed dataset
>
> How can I solve this?
> I looked on the internet but couldnt find a solution.
>
> Thanks,
>
> 
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