Null problem with parameter.asMemo := EmpyStr

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
EderWillian
Posts: 12
Joined: Tue 21 Aug 2007 14:25

Null problem with parameter.asMemo := EmpyStr

Post by EderWillian » Thu 09 Feb 2012 16:43

Hi.

I having an specific problem with 5.0.2 Driver and MSSQL2005 and Delphi XE.

The driver are changing the EmptyStr value with 'NULL'.

1- Delphi Code
SQLQuery1.Close;
SQLQuery1.SQL.Text := 'Select 1 Where ''1'' = :pString';
SQLQuery1.Params.ParamByName('pString').asMemo := EmptyStr;
SQLQuery1.Open;

2-SQL Generated statement obtained by SQLServer Profiler
exec sp_executesql N'Select 1 Where ''1'' = @P1',N'@P1 varchar(1)',NULL


Does anybody has an idea?

Best Reghards

Eder

AndreyZ

Post by AndreyZ » Fri 10 Feb 2012 09:03

Hello,

To avoid this problem, you should use the AsString property instead of AsMemo. Here is an example:

Code: Select all

SQLQuery1.Close; 
SQLQuery1.SQL.Text := 'Select 1 Where ''1'' = :pString'; 
SQLQuery1.Params.ParamByName('pString').AsString := EmptyStr; 
SQLQuery1.Open;

EderWillian
Posts: 12
Joined: Tue 21 Aug 2007 14:25

Post by EderWillian » Fri 10 Feb 2012 11:26

Problem Solved.

Thank you.

AndreyZ

Post by AndreyZ » Fri 10 Feb 2012 11:59

Feel free to contact us if you have any further questions about dbExpress driver for SQL Server.

Post Reply