gpt4 book ai didi

delphi - DataSnap 代理问题

转载 作者:行者123 更新时间:2023-12-02 00:02:23 32 4
gpt4 key购买 nike

以下错误发生在我在下面指出的行中。我不明白为什么会出现此错误。

Project ChirpSR.exe raised exception class $C0000005 with message 'access violation at 0x00e8d088: read of address 0x00000000'.

下面的代码来自为 DataSnap Server 自动生成的代理类。

interface

uses Data.DBXCommon, Data.DBXClient, Data.DBXDataSnap, Data.DBXJSON, Datasnap.DSProxy, System.Classes, System.SysUtils, Data.DB, Data.SqlExpr, Data.DBXDBReaders, Data.DBXCDSReaders, Data.DBXJSONReflect;

....
type
TServerMethods1Client = class(TDSAdminClient)
private
FEchoStringCommand: TDBXCommand;
FReverseStringCommand: TDBXCommand;
FGetValleysCommand: TDBXCommand;
FUpdateUserCommand: TDBXCommand;
public
constructor Create(ADBXConnection: TDBXConnection); overload;
constructor Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean); overload;
destructor Destroy; override;
function EchoString(Value: string): string;
function ReverseString(Value: string): string;
function GetValleys: TJSONValue;
function UpdateUser(jsonobj: TJSONObject): Integer;
end;
....
// This function runs fine
function TServerMethods1Client.GetValleys: TJSONValue;
begin
if FGetValleysCommand = nil then
begin
FGetValleysCommand := FDBXConnection.CreateCommand;
FGetValleysCommand.CommandType := TDBXCommandTypes.DSServerMethod;
FGetValleysCommand.Text := 'TServerMethods1.GetValleys';
FGetValleysCommand.Prepare;
end;
FGetValleysCommand.ExecuteUpdate;
Result := TJSONValue(FGetValleysCommand.Parameters[0].Value.GetJSONValue(FInstanceOwner));
end;

// This function errors at the highlighted line
function TServerMethods1Client.UpdateUser(jsonobj: TJSONObject): Integer;
begin
if FUpdateUserCommand = nil then
begin
FUpdateUserCommand := FDBXConnection.CreateCommand; <============= Error Here
FUpdateUserCommand.CommandType := TDBXCommandTypes.DSServerMethod;
FUpdateUserCommand.Text := 'TServerMethods1.UpdateUser';
FUpdateUserCommand.Prepare;
end;
FUpdateUserCommand.Parameters[0].Value.SetJSONValue(jsonobj, FInstanceOwner);
FUpdateUserCommand.ExecuteUpdate;
Result := FUpdateUserCommand.Parameters[1].Value.GetInt32;
end;
....

服务器正在运行,否则第一个函数会出错。

我被难住了。

我也是 DataSnap 的新手。

最佳答案

Project ChirpSR.exe raised exception class $C0000005 with message 'access violation at 0x00e8d088: read of address 0x00000000'.

错误消息提示您的情况FDBXConnection = nil。由于CreateCommand是虚拟方法,调用TDBXConnection(nil).CreateCommand将产生您提出的异常。

关于delphi - DataSnap 代理问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22102294/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com