Delphi7 WebService and Database

xiaoxiao2021-03-06  77

Server end:

Add Adoconnection1, AdodataSet1, DataSetProvider1; DataSetProvider1 DataSet Set to AdoDataSet1; AdoDataSet1's CommandText Set is emmandtext set to Adoconnection1. DataRequest events of DataSetProvider1:

Function TDataMod.DataSetProvider1DataRequest (Sender: TOBJECT)

Input: Olevariant: olevariant;

Begin

IF adoconnection1.connected the

Begin

AdoDataSet1.commandtext: = input;

Result: = datasetProvider1.data;

END;

END;

procedure TDataMod.SoapDataModuleCreate (Sender: TObject); var DataPath: string; const SQL: string = 'Provider = Microsoft.Jet.OLEDB.4.0; Data Source = E: / programs / Delphi7 / Demos / WebServices / SOAPDataModule / Data / Tree .mdb; Persist Security Info = False '; begin DataPath: = ExtractFilePath (Application.ExeName) ' ../Data/ '; XMLTransformProvider1.XMLDataFile: = DataPath ' XML_Document.xml '; XMLTransformProvider1.TransformRead.TransformationFile: = DataPath 'ToDp.xtr'; XMLTransformProvider1.TransformWrite.TransformationFile: = DataPath 'ToXml.xtr'; try ADOConnection1.Connected: = false; ADOConnection1.ConnectionString: = SQL; ADOConnection1.Connected: = true; except // showmessage (A_ParentPath 'DATA / INFOMAT.MDB call failed'); END;

Client end:

SOAPCONNECTION1, ClientDataSet1; ClientDataSet1's ConnectionBroker property is SOAPCONNECTION1, the ProviderName property is a DataSetProvider1 query record set:

Procedure TclientForm.Button1Click (Sender: TOBJECT);

Var SQL: String;

Begin

IF not soapconnection1.connected then

Begin

SOAPCONNECTION1.URL: = urllist.text '/ soap / idataMod'

SOAPCONNECTION1.OPEN

END;

SQL: = Edit1.Text;

With clientdatanet1 dobegin

Data: = DATAREQUEST (SQL);

END;

END;

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

New Post(0)