嗨,EveryBody!
我是编程新手!
我需要你的帮助。
我有2个项目:
1。项目登录页面。 使用App Tethering 和2个按钮(Connect按钮=>连接到服务器AND Login按钮=>向服务器发送请求以检查有效的用户名和密码)。
2。 Project Server页面。在使用App tethering和FDQuery +的服务器页面中( SQLite 数据库test.db)。 当客户端连接到服务器并向服务器发送请求以检查有效的用户名和密码时,它会给出错误的结果。 PLZ帮助我正确地开展工作。
1项目代码:
procedure TfAuth.bLogin(Sender: TObject);
begin
tAProfile.SendString(tManager.RemoteProfiles.First,'Login',tLogin.Text);
tAProfile.SendString(tManager.RemoteProfiles.First,'Password',tPassword.Text);
end;
2。项目代码: 我创建了全局变量
private
{ Private declarations }
public
{ Public declarations }
end;
var
aLogin, aPassword:string;
implementation
{$R *.fmx}
然后我把这段代码放在TetherAppProfile => OnResourceReceived :
procedure TfServerPage.tAProfileResourceReceived(const Sender: TObject;
const AResource: TRemoteResource);
begin
if AResource.Hint='Login' then
begin
aLogin:=AResource.Value.AsString;
end;
if AResource.Hint='Password' then
begin
aPassword:=AResource.Value.AsString;
end;
rQuery.Close;
rQuery.SQL.Clear;
rQuery.SQL.Add('select * from authoriation where name='+QuotedStr(aLogin)+'and password='+QuotedStr(aPassword));
rQuery.Open;
if rQuery.RecordCount=0 then // No record found for user
ShowMessage('Be sure user name and password is correct')
else
begin
ShowMessage('Success!');
end;
答案 0 :(得分:1)
修改您的代码,如下所示:
在客户端
{{event.start_time | date : 'date_format'}}
注意!这使用名为“Login”的服务器资源。
在服务器
中procedure TfAuth.bLogin(Sender: TObject);
var
s: string;
begin
s := tLogin.Text + #13 + tPassword.Text;
tAProfile.SendString(tManager.RemoteProfiles.First,'Login',s);
// tAProfile.SendString(tManager.RemoteProfiles.First,'Login',tLogin.Text);
// tAProfile.SendString(tManager.RemoteProfiles.First,'Password',tPassword.Text);
end;
使用procedure TfServerPage.tAProfileResourceReceived(const Sender: TObject;
const AResource: TRemoteResource);
var
s: string;
begin
// replace current code before rQuery.Close with the following
s := AResource.Value.AsString;
aLogin := copy(s, 1, Pos(#13, s)-1);
aPassword := copy(s, Pos(#13, s)+1, Length(s));
rQuery.Close;
// continue with rQuery
// ...
end;
SplitString()