程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi7的WebService與數據庫

Delphi7的WebService與數據庫

編輯:Delphi
Server 端:

  SoapDataModule中加入 ADOConnection1、ADODataSet1、DataSetProvider1;DataSetProvider1的DataSet設置為ADODataSet1;ADODataSet1的CommandText設置為空,Connection設置為ADOConnection1。

  DataSetProvider1的DataRequest事件:





  function TDataMod.DataSetProvider1DataRequest(Sender: TObject;
  Input: OleVariant): OleVariant;
  begin
  if ADOConnection1.Connected then
  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 調用失敗');
  end;
  end;
  ClIEnt端:

  SoapConnection1、ClientDataSet1;ClIEntDataSet1的ConnectionBroker屬性為SoapConnection1,ProviderName屬性為DataSetProvider1

  查詢記錄集:


  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 ClIEntDataSet1 do
  begin
  Data := DataRequest(SQL);
  end;
  end;

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved