【发布时间】:2017-02-05 19:09:37
【问题描述】:
我有客户端和服务器应用程序。 我在双方都使用 App tethering。 在服务器端,我有 SQLite 数据库 在客户端没有数据库; 客户端从服务器数据库获取数据。 使用服务器代码,我认为没问题。客户有问题,我不能拆分!!!我在 Client Side 上写了代码。谁能告诉我,我的错误在哪里??? 如何拆分 r3.Text:=AResource.Value.AsString; ?
服务器端代码:
procedure TfServerPage.tAProfileResourceReceived(const Sender: TObject;
const AResource: TRemoteResource);
var
result:string;
r1,r2,r3:TstringList;
begin
if AResource.Hint='List' then
begin
//ShowMessage(AResource.Value.AsString);
r1:=TStringList.Create;
r2:=TStringList.Create;
r3:=TStringList.Create;
rQuery.Open;
while not rQuery.Eof do
begin
r1.add(rQuery.FieldByName('username').AsString);
r2.add(rQuery.FieldByName('password').AsString);
r3.add(rQuery.FieldByName('nickname').AsString);
rQuery.Next;
end;
result:=r1.Text+#13+r2.Text+#13+r3.text;
tAProfile.SendString(tManager.RemoteProfiles.First,'List2',result);
end;
end;
客户端代码:
procedure TfAuth.tAProfileResourceReceived(const Sender: TObject;
const AResource: TRemoteResource);
var i:integer;
r3,s1,s2,s3:TStringList;
begin
if AResource.Hint='List2' then
begin
r3:=TStringList.Create;
r3.Text:=AResource.Value.AsString; // <-From Server
s1:=TStringList.Create;
s2:=TStringList.Create;
s3:=TStringList.Create;
s1.Text:=SplitString(r3.Text,#13)[0]; //Split username
s2.Text:=SplitString(r3.Text,#13)[1]; //password
s3.Text:=SplitString(r3.Text,#13)[2]; //nickname
for i := 0 to r3.Count do
begin
StringGrid1.Cells[0,i]:=s1[i];
StringGrid1.Cells[1,i]:=s2[i];
StringGrid1.Cells[2,i]:=s3[i];
end;
end;
end;
【问题讨论】:
-
我认为你应该写
s1.Add (SplitString(r3.Text,#13)[0] );而不是s1.Text:=SplitString(r3.Text,#13)[0];`
标签: delphi