上次,我不是说的很清楚吗?
1、在type library中定义的方法后,要按refresh Imp...更新,然后最就再MYserver.pas中找到方式的系统定义,在相应的位置输入代码就OK。
2、还不行,请见代码。
unit srvdata;//srvdata.pas
interface
uses
Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
DBClient, srvwh9_TLB,forms, StdVcl, DBTables, Db,IniFileS, Provider;
type
Tclssrv = class(TRemoteDataModule, Iclssrv)
whdb: TDatabase;
Ses1: TSession;
Qpub: TQuery;
Qent_kind: TQuery;
Qgoodslist: TQuery;
Qmater: TQuery;
Qkcolor: TQuery;
Qunit: TQuery;
Qpurch: TQuery;
spget_goods_list: TStoredProc;
Qgdgd: TQuery;
Qmat_dbd: TQuery;
Qmat_dbds: TQuery;
Qgoods_dg: TQuery;
Qord_b: TQuery;
Qmat_dord: TQuery;
spgoods_in: TStoredProc;
Qdg_mat: TQuery;
Qgdgd_odr: TQuery;
Qmat_issize: TQuery;
Qclass: TQuery;
QPgetmat: TQuery;
Qstock: TQuery;
spcorder_std: TStoredProc;
QPrenew: TQuery;
Qtotal_mat: TQuery;
spstock_out: TStoredProc;
Qfill_mat: TQuery;
QBmat_k: TQuery;
QBmat_lk: TQuery;
Qgoods_v: TQuery;
Qccheck_stock_n_v: TQuery;
spysrkd1: TStoredProc;
spcjudge_check: TStoredProc;
spccheck_stock: TStoredProc;
spcheck_cancel: TStoredProc;
spcday_mat_outin: TStoredProc;
Qstock_mat: TQuery;
spmat_inoutlist: TStoredProc;
spcstock_list: TStoredProc;
spcorder_mat: TStoredProc;
spcprim_mat: TStoredProc;
spstock_min_mat: TStoredProc;
spcexc_mat: TStoredProc;
sppurch_exit: TStoredProc;
spcxhpdzb: TStoredProc;
spcdepartcount: TStoredProc;
spcdeplete_in_out: TStoredProc;
spcheck_pay: TStoredProc;
spcdeplete_count: TStoredProc;
Qoutbill: TQuery;
Qdg_outord: TQuery;
Qdg_cmat: TQuery;
Qoutbill_v: TQuery;
Qgoods_list_vw: TQuery;
Qorder_stock: TQuery;
QCorder_stock: TQuery;
spother_stock: TStoredProc;
Qdg_stcok_vw: TQuery;
Qchldmat: TQuery;
spprud_check: TStoredProc;
spmat_check_ent: TStoredProc;
Qissysobjects: TQuery;
Qmat_order: TQuery;
spdelmat_order: TStoredProc;
Qpurch_mat: TQuery;
Qgoods: TQuery;
Qdg_ord: TQuery;
spcstock_in: TStoredProc;
spcheck_list: TStoredProc;
Qstocksum: TQuery;
Qout_dg: TQuery;
Qdg_mmat: TQuery;
spbillmat_stock: TStoredProc;
Ppub: TDataSetProvider;
Pkuser: TDataSetProvider;
Pmat_dbds: TDataSetProvider;
Pdg_cmat: TDataSetProvider;
qkuserlst: TQuery;
Qkoprec: TQuery;
Qkoprecautoid: TAutoIncField;
Qkoprecrq: TDateTimeField;
Qkoprecxq: TStringField;
Qkoprecuser_name: TStringField;
Qkoprecenter: TDateTimeField;
Qkoprecoperation: TStringField;
Qkoprecquit: TDateTimeField;
Qkuser: TQuery;
Qart_size: TQuery;
Qout_kind: TQuery;
Qstk_min: TQuery;
Part_size: TDataSetProvider;
pkuserlst: TDataSetProvider;
Pkoprec: TDataSetProvider;
pout_kind: TDataSetProvider;
pent_kind: TDataSetProvider;
pstk_min: TDataSetProvider;
poutbill: TDataSetProvider;
ppurch: TDataSetProvider;
pgoodslist: TDataSetProvider;
Pmat_dbd: TDataSetProvider;
Pcalss: TDataSetProvider;
Pstock: TDataSetProvider;
PBmat_k: TDataSetProvider;
Pord_b: TDataSetProvider;
Pstock_mat: TDataSetProvider;
pissysobjects: TDataSetProvider;
Pgoods: TDataSetProvider;
pday_mat_outin: TDataSetProvider;
Pmat_inoutlist: TDataSetProvider;
Pdepartcount: TDataSetProvider;
Pxhpdzb: TDataSetProvider;
pheck_pay: TDataSetProvider;
Pstock_list: TDataSetProvider;
Pcorder_stock: TDataSetProvider;
Pother_stock: TDataSetProvider;
pdg_stcok_vw: TDataSetProvider;
Pcexc_mat: TDataSetProvider;
Pstock_min_mat: TDataSetProvider;
Ppurch_exit: TDataSetProvider;
Pcdeplete_count: TDataSetProvider;
Pchldmat: TDataSetProvider;
Pdg_mat: TDataSetProvider;
Pdg_ord: TDataSetProvider;
Pdg_outord: TDataSetProvider;
Pfill_mat: TDataSetProvider;
Pgdgd_odr: TDataSetProvider;
Pgoods_list_vw: TDataSetProvider;
Pkcolor: TDataSetProvider;
Pmat_dord: TDataSetProvider;
Pmat_issize: TDataSetProvider;
Pmat_order: TDataSetProvider;
Pmater: TDataSetProvider;
Porder_stock: TDataSetProvider;
Pout_dg: TDataSetProvider;
Poutbill_v: TDataSetProvider;
PPrenew: TDataSetProvider;
Ppurch_mat: TDataSetProvider;
Pstocksum: TDataSetProvider;
Ptotal_mat: TDataSetProvider;
Punit: TDataSetProvider;
Ppbillmat_stock: TDataSetProvider;
Ppccheck_stock: TDataSetProvider;
Ppcdeplete_count: TDataSetProvider;
Ppcdeplete_in_out: TDataSetProvider;
Pgdgd: TDataSetProvider;
Ppcheck_cancel: TDataSetProvider;
Ppcjudge_check: TDataSetProvider;
Ppcheck_list: TDataSetProvider;
Ppcorder_mat: TDataSetProvider;
Ppcorder_std: TDataSetProvider;
Ppcprim_mat: TDataSetProvider;
Ppcstock_in: TDataSetProvider;
Ppdelmat_order: TDataSetProvider;
Ppget_goods_list: TDataSetProvider;
Ppgoods_in: TDataSetProvider;
Ppmat_check_ent: TDataSetProvider;
Ppstock_min_mat: TDataSetProvider;
Ppprud_check: TDataSetProvider;
Ppstock_out: TDataSetProvider;
Ppysrkd1: TDataSetProvider;
Pdg_mmat: TDataSetProvider;
Qmatermatcolor_no: TStringField;
Qmatermat_no: TStringField;
Qmatermat_nm: TStringField;
Qmateremat_nm: TStringField;
Qmaterrules: TStringField;
Qmatererules: TStringField;
Qmatercolor_no: TStringField;
Qmaterpur_unit: TStringField;
Qmaterunit: TStringField;
Qmaterprice: TFloatField;
Qmaterstk_min: TFloatField;
Qmaterl_kind: TStringField;
Qmaters_kind: TStringField;
Qmaterunit_rate: TFloatField;
Qmaterdays: TIntegerField;
Qmaterstk_no: TStringField;
Qmaterposin: TStringField;
Qmaterissize: TBooleanField;
Qmaterisfty: TBooleanField;
Qmaterisparent: TBooleanField;
Qmaterisinrate: TBooleanField;
Qmatersize: TStringField;
Qmaterunitage: TFloatField;
Pgetmat: TDataSetProvider;
Udg_cmat: TUpdateSQL;
Uchldmat: TUpdateSQL;
Ugdgd: TUpdateSQL;
Umat_order: TUpdateSQL;
Pgoods_v: TDataSetProvider;
Pccheck_stock_n_v: TDataSetProvider;
Upspurch_mat: TUpdateSQL;
Qsys_menu: TQuery;
Psys_menu: TDataSetProvider;
Qsysloguser: TQuery;
Psysloguser: TDataSetProvider;
procedure clssrvCreate(Sender: TObject);
procedure clssrvDestroy(Sender: TObject);
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
override;
[red] procedure update(const sqlstr: WideString);
safecall;//这是我定义的两个方式,update,select,更新后,系统自动生成
procedure select(const SQLStr: WideString;
out Data: OleVariant);
safecall; public[/red] { Public declarations }
end;
implementation
{$R *.DFM}
class procedure Tclssrv.UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
[red]procedure Tclssrv.update(const sqlstr: WideString);
begin
Qpub.Close;
Qpub.SQL.Clear;
Qpub.SQL.Add(SQLStr);
Qpub.ExecSQL;
end;
[/red]
procedure Tclssrv.clssrvCreate(Sender: TObject);
var srvini: TIniFile;
srvstrs: TStrings;
exepath:String;
begin
exepath:=ExtractFilePath(Application.ExeName);
srvini := TIniFile.Create(Pchar(exepath+'config.ini'));
srvstrs := TStringList.Create ;
srvini.ReadSectionValues('Server Config',srvstrs);
If trim(srvstrs.Values['SERVER NAME']) <> '' then
begin
If whdb.Connected =True then
whdb.Connected:=false;
whdb.Params.Values['SERVER NAME'] := srvstrs.Values['Server Name'] ;
whdb.Params.Values['DATABASE NAME'] := srvstrs.Values['DATABASE NAME'] ;
end;
SrvIni.Free;
srvstrs.Free ;
end;
[red]procedure Tclssrv.select(const SQLStr: WideString;
out Data: OleVariant);
begin
Qpub.SQL.Text := SQLStr;
Data :=ppub.Data;
end;
[/red]
procedure Tclssrv.clssrvDestroy(Sender: TObject);
begin
whdb.Connected:=False;
end;
initialization
TComponentFactory.Create(ComServer, Tclssrv,
Class_clssrv, ciMultiInstance, tmApartment);
end.
明白了吧。