'Retrieving data with single quote from dataset (Delphi)
Currently I have something like but I'm unable to retrieve my data from the dataset when it has single quote in the data
procedure TForm1.AfterConstruction;
begin
inherited;
cdsMain.FieldDefs.Add('ItemCode', ftWideString, 20);
cdsMain.CreateDataSet;
cdsDetail.FieldDefs.Add('ItemCode', ftWideString, 20);
cdsDetail.FieldDefs.Add('Project', ftWideString, 20);
cdsDetail.CreateDataSet;
var S := '6x8''''';
cdsMain.AppendRecord([S]);
cdsDetail.AppendRecord([S, 'P01']);
cdsDetail.AppendRecord([S, 'P02']);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if FDConnection1.Connected then
FDConnection1.Close;
if FDLocalSQL1.Active then
FDLocalSQL1.Active := False;
FDLocalSQL1.Active := True;
FDQuery1.Open('SELECT A.ItemCode, B.Project FROM Main A INNER JOIN Detail B ON (A.ItemCode=B.ItemCode)');
end;
My expected result are
ItemCode Project
6x8' P01
6x8' P02
The error I get when I use var S := '6x8''''

Source code
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
