怎么样通过bcb做三层数据库程序的应用服务器接口?
我现在用bcb做三层数据库程序,主要思路如下,在应用服务器写接口,然后在客户段直接调用来实现.现在我想浏览数据,所有的sql语句都在服务器段实现,在客户端通过调用一个方法来实现浏览的功能(如查询学生信息,调用函数,QueryStudentList()),那么在服务器段的方法为QueryStudentList(),其SQL的语句在服务器实现,这个方法应该返回什么类型供客户段调用呢,在delphi中实现如下,测试通过了: delphi程序: 服务器端程序: function TBusiness.QueryCarList: OleVariant; begin Result := DataSetToClientDataSet(FDataVisit.QueryCarList).Data; end; DataSetToClientDataSet的方法如下: function TBusiness.DataSetToClientDataSet( ADataSet: TDataSet): TClientDataSet; begin Result := TClientDataSet.Create(nil); FDataProvider.DataSet := ADataSet; Result.Data := FDataProvider.Data; end; FDataVisit.QueryCarList的方法如下: function TDataVisit.QueryCarList: TDataSet; begin CheckUser(PRI_LOGIN); if (FLogUser <> SYSTEM_SUPERUSER_ID) then begin if HasPrivilege(PRI_SYSADMIN) then Result := RunSql('select car_id,car_no,car_memo,res_id from tab_carinfo where car_stat = 0') else Result := RunSql('select car_id,car_no,car_memo,res_id from view_carinfo '+ 'where user_id = '+IntToStr(FLogUser)); end else Result := RunSql('select car_id,car_no,car_memo,res_id from tab_carinfo '); end; 客户端程序: var QueryCar:tclientdataset; Car_QueryList_Info:olevariant; Query_Server:=IBusinessDisp(IDispatch(frmmain.SocketConnection.appServer)); QueryCar:=tclientdataset.Create(nil); Query_check:=twl.Create; try Car_QueryList_Info:=Query_server.QueryCarList; if not Query_check.check_ole(Car_QueryList_Info) then exit; QueryCar.Data:=Car_QueryList_Info; except on E:exception do begin if dl_sx=true then frmcsh.Close; showmessage(e.Message); exit; end; end;
本文地址:http://www.45fan.com/dnjc/73775.html