Using TDBXDataSetReader.ToClientDataSet w/ MSSQLServer drive

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
dmgarcia
Posts: 8
Joined: Tue 01 Jun 2010 14:10
Location: Brasil

Using TDBXDataSetReader.ToClientDataSet w/ MSSQLServer drive

Post by dmgarcia » Wed 09 Mar 2011 15:17

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;

AndreyZ

Post by AndreyZ » Thu 10 Mar 2011 09:48

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.

dmgarcia
Posts: 8
Joined: Tue 01 Jun 2010 14:10
Location: Brasil

Post by dmgarcia » Thu 10 Mar 2011 16:24

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

AndreyZ

Post by AndreyZ » Fri 11 Mar 2011 11:35

Please specify the exact SQL code you are using in the baseSelectChangesCommand variable.

dmgarcia
Posts: 8
Joined: Tue 01 Jun 2010 14:10
Location: Brasil

Post by dmgarcia » Fri 11 Mar 2011 12:57

Sorry for that, the baseSelectChangesCommand is declared as above:

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


Thanks

AndreyZ

Post by AndreyZ » Tue 15 Mar 2011 08:30

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.

dmgarcia
Posts: 8
Joined: Tue 01 Jun 2010 14:10
Location: Brasil

Post by dmgarcia » Wed 16 Mar 2011 15:12

Thanks I didnt noted that :/

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

Post Reply