Cannot perform this operation on a closed dataset

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
SsurferR
Posts: 3
Joined: Mon 05 Sep 2011 15:52

Cannot perform this operation on a closed dataset

Post by SsurferR » Mon 05 Sep 2011 16:46

Hello.
I'm having some problems related to comunication with application and Db.
The code below is returning these errors:

Error 1 & 2: "No SQL statement provided"
Error 3: QuerySearch: Cannot perform this operation on a closed dataset.

The sample code bellow is a part of one already taken from the PosgreSql Dataset Component forum post.
I can't understand what im missing, would apreciate a enlightenment from anyone who can help me out with this problem.

Code: Select all

unit fCadastroServicos;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TfrmCadastrarServicos = class(TForm)
    lbledtServico: TLabeledEdit;
    btnCadastrar: TButton;
    procedure btnCadastrarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmCadastrarServicos: TfrmCadastrarServicos;

implementation

uses fMain, fDataModuleCGE, TClassServicos ;

var Servico : TServicos;
{$R *.dfm}

procedure TfrmCadastrarServicos.btnCadastrarClick(Sender: TObject);
var i: Integer;
begin
  dtmCGE.conCGEDB.StartTransaction;
    try
      dtmCGE.QuerySearch.Open;
      for i:= 0 to 10 do
      begin
        dtmCGE.QuerySearch.Insert;
        dtmCGE.QuerySearch.FieldByName('descricao').AsString := 'test_'+IntToStr(i);
        //dtmCGE.SPInserirServico.Execute;
        dtmCGE.QuerySearch.Post;
      end;
      dtmCGE.conCGEDB.Commit;
      dtmCGE.QuerySearch.Close;
    Except
      dtmCGE.QuerySearch.RestoreUpdates;
      dtmCGE.conCGEDB.Rollback;
      raise;
    end;
end;

end.
-------------
Observations:
-------------

TUniConnection

Code: Select all

  object conCGEDB: TUniConnection
    ProviderName = 'PostgreSQL'
    Port = 5432
    Database = 'CGE'
    Username = 'postgres'
    Password = 'mypassword'
    Server = 'localhost'
    Connected = True
    Left = 36
    Top = 18
  end
TPostgreSQLUniProvider

Code: Select all

  object PostgreSQLUniProvider: TPostgreSQLUniProvider
    Left = 129
    Top = 18
  end
TUniQuery

Code: Select all

  object QuerySearch: TUniQuery
    Connection = conCGEDB
    Left = 219
    Top = 18
  end
StoreProcedure to insert Servico

Code: Select all

  object SPInserirServico: TUniStoredProc
    StoredProcName = 'inserir_servico'
    Connection = conCGEDB
    Left = 51
    Top = 183
    ParamData = 
    CommandStoredProcName = 'inserir_servico'
  end
SQL Table Information (Table is Already created this is just info purpose):

Code: Select all

CREATE TABLE Servicos (
  CodServicos Serial NOT NULL,
  Descricao TEXT NOT NULL,
  PRIMARY KEY(CodServicos)
);

99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

Post by 99Percent » Tue 06 Sep 2011 03:34

what is the SQL.Text property of QuerySearch?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 06 Sep 2011 10:20

Hello,

Please send us the entire project, including the scripts for creating tables and procedures, to alexp*devart*com, and specify which actions result in the error messages you have sent.

SsurferR
Posts: 3
Joined: Mon 05 Sep 2011 15:52

Post by SsurferR » Tue 06 Sep 2011 20:58

AlexP wrote:Hello,

Please send us the entire project, including the scripts for creating tables and procedures, to alexp*devart*com, and specify which actions result in the error messages you have sent.
I send'ed you the entire project and scripts on the email address you provide.
tank you.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 07 Sep 2011 10:39

Hello,

I have received your project; in the Query.SQL.Text property you did not specify a query, which is why you receive the No SQL statement provided" error message.

Please specify in more details the point, at which you receive the "Cannot perform this operation on a closed dataset" error message.

Post Reply