Page 1 of 1

[patch_done] ADO - SetParams->Reopen : failure!

Posted: 06.10.2010, 22:02
by aperger
Hi All,

I did some test with ADO protocol under D2010 (with the latest 7.0 testing branch).

You can see my simple example bellow.

If cbWithANSIParams.Checked is false, we got one line from the DB.
If cbWithANSIParams.Checked is true, the first execution provides empty resultset. But what about with the second:
1. if I call the "qRiportokNevTipus.ParamCheck:=true;" (at the moment in the comment) the program provides one record from the database,
2. if not I got empty resultset.

So... I should call ParamCheck:=true to refresh the params...

Can somebody help me?

Attila

Code: Select all

unit UMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ZConnection,
  ZAbstractRODataset, ZAbstractDataset, ZDataset, ZAbstractTable, ADODB;

type
  TForm2 = class(TForm)
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Panel1: TPanel;
    btnOpen: TButton;
    cbWithANSIParams: TCheckBox;
    Connection: TZConnection;
    qRiportokNevTipus: TZQuery;
    procedure btnOpenClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.btnOpenClick(Sender: TObject);
var
  datum: TDate;
begin

	Connection.Protocol:='ado';
	Connection.Database:='Provider=SQLNCLI10.1;Integrated Security="";'
                      +'Persist Security Info=False;User ID=sslogin;'
                      +'Initial Catalog=SmartStorage;Data Source=PERGERLPTW7;'
                      +'Initial File Name="";Server SPN=""';
  Connection.Connected:=false;
  Connection.Connected:=true;

  if cbWithANSIParams.Checked then  // Switch for FALSE param
  begin
    qRiportokNevTipus.Active:=false;
    qRiportokNevTipus.ParamByName('NEV').AsString:='AAA';
    qRiportokNevTipus.ParamByName('TIPUS').AsInteger:=1;
    qRiportokNevTipus.Active:=true;
  end;

  //if qRiportokNevTipus.Active then begin
  qRiportokNevTipus.Active:=false;
  //** OOOOOHHHH --- ***
  //qRiportokNevTipus.ParamCheck:=true;
  // If I do not call this line I got empty resultset
  // if I call ParamCheck I got results???
  //end;
  qRiportokNevTipus.ParamByName('NEV').AsString:='Fordított adózás - egészre kerekít';
  qRiportokNevTipus.ParamByName('TIPUS').AsInteger:=1;
  qRiportokNevTipus.ParamByName('NEV').DataType:=ftWideString;
  qRiportokNevTipus.Active:=true;
end;

end.

Posted: 13.10.2010, 23:49
by mdaems
Attila,

What's the query you are using? Does it contain colons ( : )?

Mark

Parameters

Posted: 14.10.2010, 08:44
by aperger
Hi,

YES! :-)


The database modul what I use for my tests it is part of my D7/ZeOS 6.6.x based solution:
http://pergersoft.hu/termekek/smartstorage

Code: Select all

SELECT
  FAZONOSITO,
  FRIPORT,
  FIDO,
  FUSER
FROM
  TRIPORTOK
WHERE
  FNEV = :NEV AND
  FTIPUS = :TIPUS
It is tested and working in production with potgresql, mysql, mssql and firebird databases.

Regards

Posted: 07.11.2010, 21:41
by mdaems
If I understand correctly this is only failing for ADO?
Or is it failing in zeoslib 7 only where it worked before in version 6.6?

As far as I understand ParamCheck *should* be used whenever you query contains colons to indicate parameters, this makes the library change the parameters to the right symbols for interpretation by the database server.

Or did the application work before without Paramcheck=true?

Mark

Posted: 08.11.2010, 08:44
by aperger
Hi,

This failure is only ADO related and only in ZeOS version 7.

This sample code running without problem(==without paramcheck ) under Delphi 7 + ZeOS 6.6 + ADO.

I try to move my D7 + ZeOS 6.6 based product into D2010. I have problem only with ZeOS 7.
This is the reason why I try to solve lots of problem at the same time.
If I have time I try to send pacthes and BUG reports...

Posted: 16.11.2010, 15:38
by aperger
Hi,

Here is my small PATCH to solve reopen problem with ADO (MSSQL/OLEDB).

Please take a look into.

Thanks.

Posted: 17.11.2010, 22:29
by mdaems
Patch done. SVN rev 854.

Mark