在安装了delphi的机器上可以正常执行,没安装的有问题(100分)

  • 主题发起人 主题发起人 fussuf
  • 开始时间 开始时间
F

fussuf

Unregistered / Unconfirmed
GUEST, unregistred user!
调用以下程序进行交叉表的生成,在安装了delphi的机器上可以正常执行,没安装的有问题,没有结果也没有出错信息。怎么办?缺少什么文件
--------------
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Dialogs, ADOINT,
adoDb,db, Forms,DBTables, StdCtrls, Comobj, ComCtrls,DBClient,Variants;

type TCrossTable =class; //生成交叉表
TCrossTable =class
private
TempTable:TClientDataSet;
Vdataset:tdataset;
tmpdataset:tclientdataset;
DataSource:Tdatasource;
tmpstrs:tstrings;
rowval,colval,dataval:string;
rowvalue :array[0..15] of string;

function CreateTmptab(const AFieldDefs:TFieldDefs):TDataSet;
function GenTemptable(SouDataSet:tdataset;field1,field3,field4:string):tdataset;
function GenCrossTable(SouDataset:tdataset;ColField,RowField,DataField:string):tdataset;
public

ds: Tdataset; // 生成的交叉表结果集
vCol:array[0..15] of string; //如果有和 RowField相关数据列可以 添加相应字段名,
{ SouDataset源数据集 ColField交叉表动态列字段 RowField交叉表行字段 DataField数据字段}
procedure GenCrossTab(SouDataset:tdataset;ColField,RowField,DataField:string);
// procedure gentest(aa:string);
end;







function TCrossTable.CreateTmptab(const AFieldDefs:TFieldDefs):TDataSet;
begin
TempTable:=nil;
Result:=nil;
if AFieldDefs<>nil then
begin
try
TempTable:=TClientDataSet.Create(Application);
TempTable.FieldDefs.Assign(AFieldDefs);
TempTable.CreateDataSet;
Result:=(TempTable as TDataSet);
Except
if TempTable<>nil then
TempTable.Free;
Result:=nil;
raise;
end
end;
end;


function TCrossTable.GenTemptable(SouDataSet:Tdataset;field1,field3,field4:string):tdataset;
var
tmpdataset:tclientdataset;
DataSource:tdatasource;
rowval,colval1,dataval:string;
i:integer;
begin
tmpdataset:=tclientdataset.Create(SouDataSet);
tmpdataset.FieldDefs.Add('f1',ftstring,50,False);
tmpdataset.FieldDefs.Add('统计汇总',ftstring,50,False);
tmpdataset.FieldDefs.Add('f3',ftstring,50,False);
DataSource:=tdatasource.Create(datasource);
DataSource.DataSet:=tmpdataset;
with DataSource do
begin
dataset:=Createtmptab(tmpdataset.FieldDefs);
dataset.Open;
end;
for i:=0 to SouDataSet.RecordCount-1 do
begin
colval1:=SouDataSet.fieldbyname(field1).AsString;
//colval2:=SouDataSet.fieldbyname(field2).AsString;
rowval:=SouDataSet.fieldbyname(field3).AsString;
dataval:=SouDataSet.fieldbyname(field4).AsString;
DataSource.DataSet.Insert;
DataSource.DataSet.FieldByName('f1').Asstring:= colval1;
DataSource.DataSet.FieldByName('统计汇总').Asstring:= rowval;
DataSource.DataSet.FieldByName('f3').Asstring:= dataval;
DataSource.DataSet.Post;
soudataset.next;
end;
result:=DataSource.DataSet;
end;




{
SouDataset源数据集
ColField交叉表动态列字段
RowField交叉表行字段
DataField数据字段
}
function TCrossTable.GenCrossTable(SouDataset:Tdataset;ColField,RowField,DataField:string):tdataset;
var
i,j,x:integer;
begin
result:=nil;
if (ColField='') or(RowField='')or(DataField='') then
showmessage('All Field not be NULL!')
else
begin
if (ColField=RowField)
or(ColField=DataField)
or(RowField=DataField) then
showmessage('All Field not be Equ!')
else
if (SouDataSet.FieldByName(ColField).DataType=ftString)
or (SouDataSet.FieldByName(ColField).DataType<>ftWideString)
or (SouDataSet.FieldByName(ColField).DataType<>ftFixedChar)
or (SouDataSet.FieldByName(ColField).DataType<>ftMemo)
or (SouDataSet.FieldByName(ColField).DataType<>ftFmtMemo) then
begin
try
tmpstrs.Free;
tmpstrs:=tstringlist.Create;
Vdataset:=SouDataSet;
Vdataset.First;
for i:=0 to Vdataset.RecordCount-1 do
begin
if (varisnull(SouDataSet.FieldValues[colfield])=false) and (SouDataSet.FieldValues[colfield]<>'') then
if tmpstrs.IndexOf(SouDataSet.FieldValues[colfield])=-1 then
begin
tmpstrs.Add(SouDataSet.FieldValues[colfield]);
end;
Vdataset.Next;
end;
//生成动态列标题
tmpdataset.Free;
tmpdataset:=TClientDataSet.Create(tmpdataset);
tmpdataset.FieldDefs.Add(rowfield,ftstring,50,False);

x:=0;
while vCol[x]<>'' do
begin
tmpdataset.FieldDefs.Add(vCol[x],ftstring,50,False);
x:=x+1;
end;
//
for i:=0 to tmpstrs.Count-1 do
begin
with tmpdataset.FieldDefs do
begin
Add(tmpstrs.Strings,ftstring,50,false);

end;
end;
tmpdataset.FieldDefs.Add('汇总',ftstring,50,false);

DataSource:=tdatasource.Create(datasource);
DataSource.DataSet:=tmpdataset;
with DataSource do
begin
dataset:=Createtmptab(tmpdataset.FieldDefs);
dataset.Open;
end;
//建立临时表
Vdataset.First;
for i:=0 to Vdataset.RecordCount-1 do
begin
rowval:=SouDataSet.fieldbyname(rowfield).AsString;
x:=0;
while vCol[x]<>'' do
begin
rowvalue[x]:=SouDataSet.fieldbyname(vCol[x]).AsString;
x:=x+1;
end;
colval:=SouDataSet.fieldbyname(colfield).AsString;
dataval:=SouDataSet.fieldbyname(datafield).AsString;
if dataval='' then dataval:='0';
if DataSource.DataSet.Locate(rowfield,rowval,[loCaseInsensitive]) then
begin
DataSource.DataSet.Edit;
DataSource.DataSet.FieldByName(colval).AsString:=floattostr(DataSource.DataSet.FieldByName(colval).Asfloat+strtofloat(dataval));
DataSource.DataSet.FieldByName('汇总').Asstring:= floattostr(DataSource.DataSet.FieldByName('汇总').asfloat+strtofloat(dataval));
DataSource.DataSet.Post;
end
else
begin
DataSource.DataSet.Append;
DataSource.DataSet.FieldByName(rowfield).AsString:=rowval;
x:=0;
while vCol[x]<>'' do
begin
DataSource.DataSet.FieldByName(vCol[x]).AsString:=rowvalue[x];
x:=x+1;
end;
for j:=1 +x to DataSource.DataSet.Fields.Count-1 do
DataSource.DataSet.Fields[j].AsCurrency:=0;
DataSource.DataSet.FieldByName(colval).AsString:=dataval;
DataSource.DataSet.FieldByName('汇总').AsString:=dataval;
DataSource.DataSet.Post;

end;
Vdataset.Next;
end;
tmpstrs.Free;
result:=DataSource.DataSet;
//生成交叉表数据集

except
end;
end
else
showmessage('ColField Must be of Type String!') ;
end;
end;

procedure TCrossTable.GenCrossTab(SouDataset:tdataset;ColField,RowField,DataField:string);
begin
ds:=GenCrossTable(SouDataset,ColField,RowField,DataField);
end;


end.
 
可能是delphi的DBE驱动的问题.
 
你用到TClientDataSet了,没安装DELPHI有没有注册MIDAS.DLL呢?注册后试试
 
用installshied打包
 
什么错误呢?有可能是少了一些DLL文件没有打包进来,
 
打包少了文件,应该是MIDAS.DLL这个文件,若还不行可能还少一些 *.bpl 文件,你可以先考的试试,然后再把这些文件地块打进去就可以了
 
谢谢各位
 
后退
顶部