Incorrect TMSSQL.Assign() method

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
may
Posts: 4
Joined: Wed 09 Jun 2010 12:05

Incorrect TMSSQL.Assign() method

Post by may » 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.

Dimon
Devart Team
Posts: 2888
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 09 Jun 2010 13:34

I can not reproduce the problem.
Please, try to download the latest SDAC build (4.80.0.58) and check if this problem still exists.

may
Posts: 4
Joined: Wed 09 Jun 2010 12:05

Post by may » Thu 10 Jun 2010 12:09

The Parameter DataType specified in TMSSQLEditor must be "Memo" or "Blob" :!: . For other datatypes method works correctly.

Sorry for incomplete explanation in the first message.

I'm using version 4.7 and try to download last version, nothing to happen with it.

Dimon
Devart Team
Posts: 2888
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 11 Jun 2010 08:55

On assigning blob parameters only reference to Blob object is copied. It's done to prevent copying of large memory amounts for blob objects.
To create new objects for blob parameters you can use the following code:

Code: Select all

  MSSQL2.Assign(MSSQL1);
  for i := 0 to MSSQL2.Params.Count - 1 do begin
    if MSSQL2.Params[i].DataType in [ftMemo{$IFDEF VER10P}, ftWideMemo{$ENDIF}, ftBlob] then begin
      MSSQL2.Params[i].DataType := ftUnknown;
      MSSQL2.Params[i].DataType := MSSQL1.Params[i].DataType;
      MSSQL2.Params[i].Value := MSSQL1.Params[i].Value;
    end;
  end;

may
Posts: 4
Joined: Wed 09 Jun 2010 12:05

Post by may » Fri 11 Jun 2010 11:01

Thanks for advice. I must to guess myself :? , the source is open...

So you find such behavior of the Assign() necessary. However it's a news for me.

Dimon
Devart Team
Posts: 2888
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 11 Jun 2010 14:43

If there is anything else I can help you with, please contact me.

may
Posts: 4
Joined: Wed 09 Jun 2010 12:05

Post by may » Wed 16 Jun 2010 05:37

Dimon wrote:If there is anything else I can help you with, please contact me.
Ok :wink:
(Imho) Since TPersistemt.Assign() overriden by TDAParam.Assign() with a specific behavior, it will be wanted to read about in SDAC's Help.

Dimon
Devart Team
Posts: 2888
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 16 Jun 2010 08:25

Thank you for your inquiry. We will investigate the possibility of adding this inforamation in the near future.

Post Reply