Page 1 of 1

Using TDBXDataSetReader.ToClientDataSet w/ MSSQLServer drive

Posted: Wed 09 Mar 2011 15:17
by dmgarcia
Hi guys I was trying to use the TDBXDataSetReader.ToClientDataSet but I'm getting the error 'Feature not implemented' can someone point me on how to use it with devart driver ?

here is my code:

Code: Select all

function TSyncAction.HasChanges(connection: TDBXConnection; TableName: string; out changes: TClientDataSet): Boolean;
var
 sqlCommand: TDBXCommand;
 sincronizedParam: TDBXParameter;
 sqlResults: TDBXReader;
begin
 Result := False;

 if Assigned(connection) then
  begin
    if connection.IsOpen then
     begin 
      sqlCommand := connection.CreateCommand;
      try
        sqlCommand.Text := Format(baseSelectChangesCommand, [TableName]);
        sincronizedParam := sqlCommand.CreateParameter;
        sincronizedParam.DataType := TDBXDataTypes.WideStringType;
        sincronizedParam.Value.SetWideString('N');

        sqlCommand.Parameters.AddParameter(sincronizedParam);

        sqlCommand.Prepare;

        sqlResults := sqlCommand.ExecuteQuery;


        changes := TDBXDataSetReader.ToClientDataSet(nil, sqlResults, False); //The error is raised here

        Result := not changes.IsEmpty;

       finally
         sqlResults.Free;
         sqlCommand.Free;
       end;
     end
      else
        raise Exception.Create('Connection Closed!');
  end;
end;

Posted: Thu 10 Mar 2011 09:48
by AndreyZ
Hello,

I cannot reproduce the problem. Please specify the following information:
- the table structure (script) you are using;
- the exact version of DbxSda;
- version of your IDE;
- version of SQL Server.

Posted: Thu 10 Mar 2011 16:24
by dmgarcia
The table is very simple I will post its structure at the end of this message.

I'm using the latest version of the driver, I've downloaded yesterday from my download area.

I'm using with mssql 2000 and 2005 with delphi 2010.

Code: Select all

CREATE TABLE [dbo].[tb_os](
	[cdemp] [int] NULL,
	[numero] [numeric](18, 0) NOT NULL,
	[cdcli] [char](6) NULL,
	[cdvend] [char](6) NULL,
	[dtemissao] [datetime] NULL,
	[contato] [char](25) NULL,
	[hr_inicial] [datetime] NULL,
	[hr_final] [datetime] NULL,
	[vr_seguro] [float] NULL,
	[vr_desconto] [float] NULL,
	[vr_total] [float] NULL,
	[ccusto] [char](20) NULL,
	[cdcusto] [char](10) NULL,
	[os_status] [char](2) NULL,
	[tipo_chamada] [char](2) NULL,
	[instrucoes] [text] NULL,
	[login_name] [char](25) NULL,
	[dt_criacao] [datetime] NULL,
	[dt_alteracao] [datetime] NULL,
	[situacao] [char](1) NULL,
	[c_key_log] [bigint] NULL,
	[horas_extras] [datetime] NULL,
	[horas_normais] [datetime] NULL,
	[numnota] [char](6) NULL,
	[vr_tot_serv] [numeric](18, 2) NULL,
	[qt_tot_serv] [numeric](18, 0) NULL,
	[custo_hr_normal] [numeric](18, 2) NULL,
	[custo_serv] [numeric](18, 2) NULL,
	[custo_he] [numeric](18, 2) NULL,
	[vr_pago_ps] [float] NULL,
	[desc_fecha] [text] NULL,
	[sincronizado] [nvarchar](1) NULL,
 CONSTRAINT [PK_tb_os] PRIMARY KEY CLUSTERED 
(
	[numero] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


ALTER TABLE [dbo].[tb_os]  WITH CHECK ADD  CONSTRAINT [CK_tb_os] CHECK  (([sincronizado] = 'N' or [sincronizado] = 'S'))
GO

ALTER TABLE [dbo].[tb_os] CHECK CONSTRAINT [CK_tb_os]
GO

ALTER TABLE [dbo].[tb_os] ADD  CONSTRAINT [DF_tb_os_sincronizado]  DEFAULT (N'N') FOR [sincronizado]
GO

Posted: Fri 11 Mar 2011 11:35
by AndreyZ
Please specify the exact SQL code you are using in the baseSelectChangesCommand variable.

Posted: Fri 11 Mar 2011 12:57
by dmgarcia
Sorry for that, the baseSelectChangesCommand is declared as above:

const
baseSelectChangesCommand = 'select * from %s where sincronizado = ?';


Thanks

Posted: Tue 15 Mar 2011 08:30
by AndreyZ
Text columns in your table cause this error. This is a RAD Studio problem, and not connected with DbxSda. This error is generated by RAD Studio in the TDBXByteArrayValue.SetDynamicBytes method. Here is a code that generates this error:

Code: Select all

if FDbxRow  nil then
begin
  FGeneration := FDbxRow.Generation;
  FDbxRow.ValueSet(Self);
end;
The "FDbxRow.ValueSet(Self);" code eventually calls the TDBXRow.SetDynamicBytes method that is defined in the following way:

Code: Select all

procedure TDBXRow.SetDynamicBytes(DbxValue: TDBXValue; Offset: Int64;
  const Buffer: TBytes; BufferOffset, Length: Int64);
begin
  NotImplemented;
end;
This code appeared in RAD Studio 2009. Please write about this problem to the Embarcadero support.

Posted: Wed 16 Mar 2011 15:12
by dmgarcia
Thanks I didnt noted that :/

I will try to find the solution with embarcadero team :)