问题
I have problem with Delphi XE5 Firedac application. I use ZTE Blade 3 phone to run application. I used deployment manager to add database file to assets\internal directory. But when I call FDQuery1.FieldByName('Nimi').AsString it raises exception Segmentation fault (11).Thanks.
FDQuery1.SQL.Clear;
FDQuery1.SQL.Add('SELECT * FROM Laskuttaja');
FDQuery1.Open();
FDQuery1.First;
while(not FDQuery1.Eof) do begin
FormTiedot.EditNimi.Text := FDQuery1.FieldByName('Nimi').AsString;
FormTiedot.EditOsoite.Text := FDQuery1.FieldByName('Osoite').AsString;
FormTiedot.EditY.Text := FDQuery1.FieldByName('Ytunnus').AsString;
FDQuery1.Next;
end;
if FormTiedot.ShowModal = mrOk then begin
FDQuery1.SQL.Clear;
FDQuery1.SQL.Add('UPDATE Laskuttaja SET Nimi = '+QuotedStr(FormTiedot.EditNimi.Text)+', Osoite = ' + QuotedStr(FormTiedot.EditOsoite.Text) + ', Ytunnus=' + QuotedStr(FormTiedot.EditY.Text));
FDQuery1.SQL.Add('WHERE ID=1');
回答1:
The error occurs on this line:
FormTiedot.EditNimi.Text := FDQuery1.FieldByName('Nimi').AsString;
A segmentation fault means that you are referring to invalid memory. So, this could arise for at least one of the following reasons:
FormTiedot
is invalid.FormTiedot.EditNimi
is invalid.FDQuery1
is invalid.FDQuery1.FieldByName('Nimi')
returnsnil
.
Now, as far as I know, FieldByName()
raises an exception to indicate failure, rather than returning nil
. And FDQuery1
is surely valid, otherwise the earlier code would have failed.
So, the most likely conclusion is that either FormTiedot
or FormTiedot.EditNimi
are invalid. Perhaps you failed to instantiate FormTiedot
?
回答2:
I was able to solve (I compiled and the error gives in function function "TClientModule1.GetServerMethods1Client: TServerMethods1Client;" when accessing the class FServerMethods1Client... Go to menu: Project -> Options -> Forms;
Verify that TClientModule1 is first in the Auto-Create forms.
来源:https://stackoverflow.com/questions/20839990/android-delphi-application-segmentation-fault-11-exception-when-calling-fireda