我有客户端和服务器应用程序。
在客户端我授权。 在服务器端,我有SQLite数据库。
在客户端使用:应用程序网络共享(TTetheringAppProfile和TTetheringManager),2个编辑和2个按钮(连接按钮和登录按钮)......
在服务器端使用:App tethering(TTetheringAppProfile和TTetheringManager),SQLite数据库,TFDConnection,TFDQuery ......
客户端使用APP TETHERING将数据发送到服务器数据库进行检查。如果用户名和密码正确它应该显示我MessageBox('成功!!!')。否则MessageBox('确保用户名和密码正确');
客户端代码:
procedure TfAuth.Button2Click(Sender: TObject);
begin
tAProfile.SendString(tManager.RemoteProfiles[0],'Login',tLogin.Text);
tAProfile.SendString(tManager.RemoteProfiles[0],'Password',tPassword.Text);
end;
服务器端代码:
procedure TfServerPage.tAProfileResourceReceived(const Sender: TObject;
const AResource: TRemoteResource);
var aLogin, aPassword:TStringList;
begin
aLogin:=TStringList.Create;
aPassword:=TStringList.Create;
if AResource.Hint = 'Login' then
begin
aLogin.Text:=AResource.Value.AsString;
end
else if AResource.Hint = 'Password' then
begin
aPassword.Text:=AResource.Value.AsString;
end;
rQuery.Close;
rQuery.Close;
rQuery.SQL.Clear;
rQuery.SQL.Add('select * from authoriation where name='+QuotedStr(aLogin.Text)+'and password='+QuotedStr(aPassword.Text));
rQuery.Open;
if rQuery.RecordCount = 0 then
begin
ShowMessage('Be sure user name and password is correct');
end
else
begin
ShowMessage('Success!!!');
end
end;
答案 0 :(得分:0)
尝试连接到Server上的数据库并捕获结果;正确的连接或错误。
使用相同的方法向服务器发送参数,您可以使用True / False,0/1或其他方式将操作结果发送到客户端。您也可以use Shared resources执行相同的操作/通信。
您可以这样做:
TtetheringAppProfile
)中,您可以定义名为 SharedRes1 的共享资源,其中包含:IsPublic=True; Kind=Shared; Name=SharedRes1; ResType=Data;
var pInfo:TTetheringProfileInfo; rRes:TRemoteResource; begin pInfo := ttManager.RemoteProfiles[0]; rRes := ttaProfile.GetRemoteResourceValue(pInfo, 'SharedRes1'); ttaProfile.SubscribeToRemoteItem(pInfo, rRes);
ttaProfile.Resources.FindByName('SharedRes1').Value := FormatDateTime('hh:nn:ss', Now)
使用此系统,您可以在两个程序之间交换不同的信息。
注意:我在代码中添加了引号,因为没有代码,代码就不能正确格式化。