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.