Strange problem in delphi 2007 with string parameters

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
PontusAtNilex
Posts: 16
Joined: Wed 03 Nov 2004 13:25

Strange problem in delphi 2007 with string parameters

Post by PontusAtNilex » Sun 13 May 2007 14:31

Hi!

i am currently testing our application in delphi 2007 and with the latest 3.20.10 MSSQL dbexpress driver.

I am using the dbexpsda30.dll driver.

I am experiencing som strange behavour with string parameters, the last characters gets cut both when doing Selects and updates against the database.

some examples from DBmonitor, and it looks the same in the sql trace.


update "PRESENTATION" set
"MINFO" = ?
where
"TYP" = ? and
"USER_ID" = ? and
"COMPONENT" = ?

Params

:1 (Memo,IN) =
:2 (String[4],IN) = 'MINF'
:3 (Int32,IN) = 21
:4 (String[8],IN) = 'frmHdpro'

Parameters :2 and :4 are not correct, they should be 'MINFO' and 'frmHdprop'.

another example

select * from EVENTS where TYPE_ = ? AND USER_ID = ?

Params
:1 (String[8],IN) = 'HD_NOTIF'
:2 (Int32,IN) = 21

:1 not correct should be 'HD_NOTIFY'.

I have debugged into dbexpress source and there the parameters seems to be correct so i really don't know where to look more.

I will try to make an easy example to verify this in D2007.

Do you have any clue of what can be the problem?

Best Regards,

Pontus

PontusAtNilex
Posts: 16
Joined: Wed 03 Nov 2004 13:25

Simple example

Post by PontusAtNilex » Sun 13 May 2007 15:36

Hello again!

I made a simple example to verify my problem and to my suprise i could
reproduce it!

My simple project.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, FMTBcd, WideStrings, StdCtrls, DB, DBClient, SqlExpr, Provider, Grids, DBGrids;

type
TForm1 = class(TForm)
SQLQuery1: TSQLQuery;
SQLConnection1: TSQLConnection;
Button1: TButton;
DataSetProvider1: TDataSetProvider;
ClientDataSet1: TClientDataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
recount : Integer;
begin
SQLQuery1.SQL.Text := 'select * from PRESENTATION where typ=:1';
SQLQuery1.Params[0].AsString := 'frmHDProp';
ClientDataSet1.Data := DataSetProvider1.GetRecords(-1, recount, Metadataoption + Resetoption)
end;

end.


----------

To my suprise this was in the sql trace:

exec sp_executesql N'select * from PRESENTATION where typ= @P1', N'@P1 varchar(8)', 'frmHDPro'

---------

Another strange thing is that DBMonitor did not catch any db activity.

Okey there is something strange here, anyone have a clue?

Best Regards,

Pontus

PontusAtNilex
Posts: 16
Joined: Wed 03 Nov 2004 13:25

BDS2006 does not show this error

Post by PontusAtNilex » Mon 14 May 2007 08:10

Hi!

I have tested the latest dbexpsda30.dll with BDS 2006 and there the parameters are correct.

Best Regards,

Pontus

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Mon 14 May 2007 12:46

Thank you for information.
We have reproduced the problem and fixed it.
This fix will be included in the next build of DbxSda.
Please watch for announcements at the forum.

Post Reply