Incorrect TMSSQL.Assign() method
Posted: Wed 09 Jun 2010 12:22
After calling the TMSSQL.Assign() method both instances (source and destination) has an own Params collection, but contents of this collection is the same.
Example:
procedure TForm1.Button1Click;
var
cmd: TMSSQL;
begin
cmd := TMSSQL.Create(Self);
// cmdTemplate here is a TMSSQL Component on my TForm1, it is a Template object, that I'm using in diffrent places.
cmd.Assign(cmdTemplate);
cmd.ParamByName('AParamName').Value := 'AnyValue';
// After that my cmdTemplate's param 'AParamValue' also have value 'AValue'.
if cmd.ParamByName('AParamName').AsString = cmdTemplate.ParamByName('AParamName').AsString then
ShowMessage('AssigneError');
end;
So that I must to set values for all params in TMSSQL each time I using it, because I don't now who was used my cmdTemplate early.
Example:
procedure TForm1.Button1Click;
var
cmd: TMSSQL;
begin
cmd := TMSSQL.Create(Self);
// cmdTemplate here is a TMSSQL Component on my TForm1, it is a Template object, that I'm using in diffrent places.
cmd.Assign(cmdTemplate);
cmd.ParamByName('AParamName').Value := 'AnyValue';
// After that my cmdTemplate's param 'AParamValue' also have value 'AValue'.
if cmd.ParamByName('AParamName').AsString = cmdTemplate.ParamByName('AParamName').AsString then
ShowMessage('AssigneError');
end;
So that I must to set values for all params in TMSSQL each time I using it, because I don't now who was used my cmdTemplate early.