BCB is a three-layer database program application server interface

xiaoxiao2021-03-06  41

I now use BCB to do a three-layer database program. The main ideas are as follows, in the application server write interface, and then call directly to the customer segment. Now I want to browse the data, all SQL statements are implemented in the server segment, in the client One way to implement browsing features (such as querying student information, call functions, querystudentlist ()), then the method of the server segment is querystudentlist (), its SQL statement is implemented in the server, this method should return what type for customer segment call , In Delphi, the test passed:

Delphi program:

Server-side program:

Function TBusiness.QueryCarlist: olevariant;

Begin

Result: = DataSetToclientDataSet (fdatavisit.querycarlist) .data;

END;

The method of DatasetToclientDataSet is as follows:

Function TBusiness.DatasettoclientDataSet (

Adataset: TDataSet: TclientDataSet;

Begin

Result: = TclientDataSet.create (nil);

FDATAPROVIDER.DataSet: = adataset;

Result.Data: = fdataProvider.data;

END;

The method of fdatavisit.queryCarlist is as follows:

Function TDataVisit.queryCarlist: tdatanet;

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 =' intent (FLOGUSER));

end

Else

Result: = Runsql ('SELECT Car_ID, Car_No, Car_Memo, Res_id from Tab_carinfo');

END;

Client program:

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).

Querycar.data:=car_querylist_info;

Except

ON E: Exception DO

Begin

IF DL_SX = True Then fmcsh.close;

ShowMessage (E.MESSAGE);

EXIT;

END;

END;

转载请注明原文地址:https://www.9cbs.com/read-67864.html

New Post(0)