解析delta得到sql语句的函数
文章作者 100test 发表时间 2011:03:17 19:33:55
来源 100Test.Com百考试题网
{解析出sql语句}
function TForm1.gensqls(AdoCon:TADOConnection. pdelta: OleVariant. const ptablename, pkeyfields: WideString): WideString.
var
i, j: integer.
s1, s2: string.
Cmdstr: string.
FieldList, Keylist: TstringList.
Cds0update: TClientDataSet.
sqlstr: WideString.
ado: TADOQuery.
begin
if varisnull(pdelta) then
Exit.
Cds0update:=TClientDataSet.Create(nil).
Cds0update.data:=pdelta.
if not Cds0update.Active then
Cds0update.Open.
try
FieldList:=TstringList.Create.
Keylist:=TstringList.Create.
Keylist.Delimiter:= , .
Keylist.DelimitedText:=pkeyfields.
ado:=TADOQuery.Create(nil).
ado.Connection:=AdoCon.
ado.sql.Text:= 0select * from ptablename where 1=0 .
ado.Open.
ado.GetFieldNames(FieldList).
ado.Free.
for i:=1 to FieldList.Count do
if Cds0update.FindField(FieldList[i-1])