Having trouble with Delphi XE2 (update2) using MS SQL 2008 R2 (sp 2) or with MS SQL 2005 (sp4).
form1.ado_m is via the TADO dataset with no parameter check using native 64 sql
var
okd:boolean;
dd:ansistring;
code snippet:
okd:=form1.ado_m.Locate('abcrow',dd,[loCaseInsensitive]);
If the value of dd ends in a single quote (it is converted to '' in the debugger) it gives a exception:
Exception class EOleException with message 'Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another'.
What is strange to me is that is a single quote character is the middle of var dd it works fine. Workaround?
The problem is caused by the number sign (#) AND quote together in the search value.
Locate use the ADO find method: The value in Criteria may be a string, floating-point number, or date. String values are delimited with single quotes or "#" (number sign) marks (for example, "state = 'WA'" or "state = #WA#").
Try to replace the number sign OR quote character by inserting records.
Another option is to use the OnFilterRecord and filtered property:
...
FSearchValue := 'A1020778014#;]_69BO'''; // private field in TForm1
ado_m.Filtered := true;
try
okd := not ado_m.IsEmpty;
finally
ado_m.Filtered := false;
end;
...
procedure TForm1.ado_mFilterRecord(DataSet: TDataSet;
var Accept: Boolean);
begin
Accept := SameText(DataSet.FieldByName('abcrow').AsString, FSearchValue);
end;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.