Delphi7的WebService与数据库

2008-02-23 07:18:55来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

  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;

上一篇: Delphi实用代码:自绘XP风格菜单
下一篇: 深入理解Delphi的消息机制

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:浅述Delphi下的OpenGL图形开发

下一篇:Delphi实用代码:自绘XP风格菜单