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
Strange problem in delphi 2007 with string parameters
-
- Posts: 16
- Joined: Wed 03 Nov 2004 13:25
-
- Posts: 16
- Joined: Wed 03 Nov 2004 13:25
Simple example
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
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
-
- Posts: 16
- Joined: Wed 03 Nov 2004 13:25
BDS2006 does not show this error
Hi!
I have tested the latest dbexpsda30.dll with BDS 2006 and there the parameters are correct.
Best Regards,
Pontus
I have tested the latest dbexpsda30.dll with BDS 2006 and there the parameters are correct.
Best Regards,
Pontus