K
kuker5
Unregistered / Unconfirmed
GUEST, unregistred user!
我要把ADOTABLE的内容导出到XML文档中,下面是我的代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls, DB, ADODB,MSXML_TLB,ComObj;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
Button1: TButton;
Button2: TButton;
XMLDocument1: TXMLDocument;
ADOTable1: TADOTable;
procedure Button1Click(Sender: TObject);
private
function makexml(adotable:Tadotable):integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
datalist:tstringlist;
do
c:IXMLDOMDocument;
root,child,child1:IXMLDomElement;
text1,text2:IXMLDOMText;
nlist:IXMLDOMNodelist;
dataRecord:String;
implementation
function TForm1.makexml(adotable:Tadotable):integer;
var
i:integer;
xml:string;
begin
try
ADOTable1.Close;
ADOTable1.Open;
xml:=adotable1.TableName;
do
c:=createoleobject('microsoft.XMLDOM')as IXMLDomDocument;
//这里提示没有定义函数CREATEOLEOBJECT
root:=doc.createElement(xml);
do
c.appendChild(root);
while not adotable1.Eof do
begin
child:=doc.createElement('Records');
root.appendChild(child);
for i:=0 to adotable1.FieldCount-1do
begin
child1:=doc.createElement(adotable1.Fields.FieldName);
child1.appendChild(doc.createTextNode(adotable1.Fields.Value));
child.appendChild(child1);
end;
adotable1.Next;
end;
do
c.save(xml+'.xml');
Result:=1;
except
on e:Exceptiondo
Result:=-1;
end;
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if makexml(adotable1)=1 then
showmessage('xml created')
else
showmessage('error');
end;
end.
编译不能通过,提示如下:
project1.exe raised excepiton class EReadError with message'property
DOMVendorDescdo
es not exist'.PROCESS STOPPED.
是什么原因,如何修改啊.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls, DB, ADODB,MSXML_TLB,ComObj;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
Button1: TButton;
Button2: TButton;
XMLDocument1: TXMLDocument;
ADOTable1: TADOTable;
procedure Button1Click(Sender: TObject);
private
function makexml(adotable:Tadotable):integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
datalist:tstringlist;
do
c:IXMLDOMDocument;
root,child,child1:IXMLDomElement;
text1,text2:IXMLDOMText;
nlist:IXMLDOMNodelist;
dataRecord:String;
implementation
function TForm1.makexml(adotable:Tadotable):integer;
var
i:integer;
xml:string;
begin
try
ADOTable1.Close;
ADOTable1.Open;
xml:=adotable1.TableName;
do
c:=createoleobject('microsoft.XMLDOM')as IXMLDomDocument;
//这里提示没有定义函数CREATEOLEOBJECT
root:=doc.createElement(xml);
do
c.appendChild(root);
while not adotable1.Eof do
begin
child:=doc.createElement('Records');
root.appendChild(child);
for i:=0 to adotable1.FieldCount-1do
begin
child1:=doc.createElement(adotable1.Fields.FieldName);
child1.appendChild(doc.createTextNode(adotable1.Fields.Value));
child.appendChild(child1);
end;
adotable1.Next;
end;
do
c.save(xml+'.xml');
Result:=1;
except
on e:Exceptiondo
Result:=-1;
end;
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if makexml(adotable1)=1 then
showmessage('xml created')
else
showmessage('error');
end;
end.
编译不能通过,提示如下:
project1.exe raised excepiton class EReadError with message'property
DOMVendorDescdo
es not exist'.PROCESS STOPPED.
是什么原因,如何修改啊.