C
cuiba
Unregistered / Unconfirmed
GUEST, unregistred user!
以下这段代码是我公司三层系统的一段连接数据代码,请同仁们研究共同学习,看看这地方有哪些不足之处或是有待改进的地方,共同探讨!并散分!300大洋!给最有idea的富翁,及方法的建议者.仅给一位,只有第一!
procedure TXRDMASCommon.XGetACDSData(const DBName, SQL: WideString;
PacketRecords, GotRecCount: Integer; var ResultData: OleVariant;
XMLData: WordBool);
var
I: Integer;
QryTemp: TADOQuery;
CDSTemp: TClientDataSet;
DSPTemp: TDataSetProvider;
begin
QryTemp := TADOQuery.Create(Self);
CDSTemp := TClientDataSet.Create(Self);
DSPTemp := TDataSetProvider.Create(Self);
try
QryTemp.Connection := GetAConnection(DBName);
DSPTemp.Name := 'CDSTemp'; {Do not localize}
DSPTemp.DataSet := QryTemp;
//if not (poAllowCommandText in DSPTemp.Options) then
//DSPTemp.Options := DSPTemp.Options + [poAllowCommandText];
DSPTemp.Options := DSPTemp.Options + [poAllowCommandText];
CDSTemp.ProviderName := DSPTemp.Name;
CDSTemp.PacketRecords := -1;
if (PacketRecords > 0) and (GotRecCount >= 0) then
CDSTemp.PacketRecords := GotRecCount + PacketRecords;
CDSTemp.CommandText := SQL;
DSRefresh(CDSTemp);
CDSTemp.First;
if GotRecCount > 0 then
begin
for I := 1 to GotRecCount do
CDSTemp.Delete;
CDSTemp.MergeChangeLog;
end;
if XMLData then
ResultData := CDSTemp.XMLData
else
ResultData := CDSTemp.Data;
//AppendToFile(ErrorFileName + '.XMLData', CDSTemp.XMLData);
finally
QryTemp.Free;
CDSTemp.Free;
DSPTemp.Free;
end;
end;
procedure TXRDMASCommon.XGetACDSData(const DBName, SQL: WideString;
PacketRecords, GotRecCount: Integer; var ResultData: OleVariant;
XMLData: WordBool);
var
I: Integer;
QryTemp: TADOQuery;
CDSTemp: TClientDataSet;
DSPTemp: TDataSetProvider;
begin
QryTemp := TADOQuery.Create(Self);
CDSTemp := TClientDataSet.Create(Self);
DSPTemp := TDataSetProvider.Create(Self);
try
QryTemp.Connection := GetAConnection(DBName);
DSPTemp.Name := 'CDSTemp'; {Do not localize}
DSPTemp.DataSet := QryTemp;
//if not (poAllowCommandText in DSPTemp.Options) then
//DSPTemp.Options := DSPTemp.Options + [poAllowCommandText];
DSPTemp.Options := DSPTemp.Options + [poAllowCommandText];
CDSTemp.ProviderName := DSPTemp.Name;
CDSTemp.PacketRecords := -1;
if (PacketRecords > 0) and (GotRecCount >= 0) then
CDSTemp.PacketRecords := GotRecCount + PacketRecords;
CDSTemp.CommandText := SQL;
DSRefresh(CDSTemp);
CDSTemp.First;
if GotRecCount > 0 then
begin
for I := 1 to GotRecCount do
CDSTemp.Delete;
CDSTemp.MergeChangeLog;
end;
if XMLData then
ResultData := CDSTemp.XMLData
else
ResultData := CDSTemp.Data;
//AppendToFile(ErrorFileName + '.XMLData', CDSTemp.XMLData);
finally
QryTemp.Free;
CDSTemp.Free;
DSPTemp.Free;
end;
end;