function replacestring(astring: string): string;
begin
result := stringreplace(astring, '&', '&', [rfreplaceall]);
result := stringreplace(result, '>', '>', [rfreplaceall]);
result := stringreplace(result, '<', '<', [rfreplaceall]);
end;
function datasettoxml(adataset: tdataset;
indent: integer): string;
var
i: integer;
indent1, indent2: string;
temp: string;
begin
indent1 := format('%*s', [indent * 2, ' ']);
indent2 := indent1 + ' ';
result := emptystr;
adataset.first;
while not adataset.eof do
begin
result := result + format('%s<%s>'#13#10, [indent1, 'record']);
for i := 0 to adataset.fieldcount - 1 do
if adataset.fields[i].datatype in [ftstring..ftautoinc, ftmemo,
ftwidestring] then
begin
temp := replacestring(adataset.fields[i].asstring)
result := result + format('%2:s<%0:s>%1:s'#13#10,
[adataset.fields[i].fieldname, temp, indent2])
end;
result := result + format('%s'#13#10, [indent1, 'record']);
adataset.next;
end;
end;
function generatexml(adataset: tdataset): string;
begin
result :=
format('<?xml version="1.0" encoding="gb2312"?>'#13#10''#13#10'%s',
[datasettoxml(adataset, 1)]);
end;
delphi中的資料庫小結
adconnection1.connectionstring provider msdaora.1 password hundsun user id hs aas data source aas hydevpub 設定資料庫連線引數 adooconnection1.commandtimeout 30...
把Excel表中的資料匯入資料庫
需求 在實現競價 時,需要把excel表中的資料週期地有條件地匯入到 位表中。這裡結合資料庫作業實現。步驟 1 生成乙個excel表 工作表名稱 website 包含的列 spid,spname,spiniprice,spincextent,spnowprice,spimage,spbidnum,s...
把資料庫中的資料匯出到excel
exec sp configure ad hoc distributed queries 0 reconfigure exec sp configure show advanced options 0 reconfigure to allow advanced options to be chang...