Page 1 of 1

Null problem with parameter.asMemo := EmpyStr

Posted: Thu 09 Feb 2012 16:43
by EderWillian
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

Posted: Fri 10 Feb 2012 09:03
by AndreyZ
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;

Posted: Fri 10 Feb 2012 11:26
by EderWillian
Problem Solved.

Thank you.

Posted: Fri 10 Feb 2012 11:59
by AndreyZ
Feel free to contact us if you have any further questions about dbExpress driver for SQL Server.