erro sql usando componente Zeos
19/11/2015
0
comocorrigir esse erro
procedure TfrClassiXml.btnImportarClick(Sender: TObject);
function GetMaxId: Integer;
begin
with TZQuery.Create(nil) do
try
Connection := DMZeos.ZConnection1;
SQL := 'Select max(ID) as ID from Classi'; da erro nessa linha
Open;
Result := FieldByName('ID').asinteger + 1;
finally
Free;
end;
end;
var
i:Integer;
begin
if cdsClassi01.Active then cdsClassi01.Close;
SetCurrentDir(ExtractFilePath(Application.ExeName));
if OpenDialog1.Execute then
begin
if OpenDialog1.FileName = '' then Exit;
cdsClassi01.LoadFromFile(OpenDialog1.FileName);
cdsClassi01.Open;
while not cdsClassi01.Eof do
begin
DataSource1.DataSet.Insert;
for i := 1 to cdsClassi01.FieldCount -1 do
begin
if DataSource1.DataSet.Fields[i].FieldName = 'ID' then
DataSource1.DataSet.FieldByName('ID').asinteger := getMaxId
else
if cdsClassi01.Fields[i].FieldKind = fkData then
DataSource1.DataSet.Fields[i].Value := cdsClassi01.Fields[i].Value;
end;
Datasource1.DataSet.Post;
TClientDataSet(DataSource1.DataSet).ApplyUpdates(0);
DataSource1.DataSet.Refresh;
cdsClassi01.Next;
end;
cdsClassi01.Close;
end
else
Exit;
mensagem:= 'O arquivo Pegasus.xml foi importado com sucesso.';
Application.MessageBox(PChar(mensagem), 'Informação', MB_OK+mb_IconInformation);
frClassiXml.Close;
end;
=========================================================================================
[Error] UClassiXml.pas(300): Incompatible types: 'TStrings' and 'String'
[Fatal Error] Pegasus.dpr(66): Could not compile used unit 'UClassiXml.pas'
procedure TfrClassiXml.btnImportarClick(Sender: TObject);
function GetMaxId: Integer;
begin
with TZQuery.Create(nil) do
try
Connection := DMZeos.ZConnection1;
SQL := 'Select max(ID) as ID from Classi'; da erro nessa linha
Open;
Result := FieldByName('ID').asinteger + 1;
finally
Free;
end;
end;
var
i:Integer;
begin
if cdsClassi01.Active then cdsClassi01.Close;
SetCurrentDir(ExtractFilePath(Application.ExeName));
if OpenDialog1.Execute then
begin
if OpenDialog1.FileName = '' then Exit;
cdsClassi01.LoadFromFile(OpenDialog1.FileName);
cdsClassi01.Open;
while not cdsClassi01.Eof do
begin
DataSource1.DataSet.Insert;
for i := 1 to cdsClassi01.FieldCount -1 do
begin
if DataSource1.DataSet.Fields[i].FieldName = 'ID' then
DataSource1.DataSet.FieldByName('ID').asinteger := getMaxId
else
if cdsClassi01.Fields[i].FieldKind = fkData then
DataSource1.DataSet.Fields[i].Value := cdsClassi01.Fields[i].Value;
end;
Datasource1.DataSet.Post;
TClientDataSet(DataSource1.DataSet).ApplyUpdates(0);
DataSource1.DataSet.Refresh;
cdsClassi01.Next;
end;
cdsClassi01.Close;
end
else
Exit;
mensagem:= 'O arquivo Pegasus.xml foi importado com sucesso.';
Application.MessageBox(PChar(mensagem), 'Informação', MB_OK+mb_IconInformation);
frClassiXml.Close;
end;
=========================================================================================
[Error] UClassiXml.pas(300): Incompatible types: 'TStrings' and 'String'
[Fatal Error] Pegasus.dpr(66): Could not compile used unit 'UClassiXml.pas'
Antonio Santos
Curtir tópico
+ 0
Responder
Posts
19/11/2015
Usuario
Antonio,
tente colocar
tente colocar
SQL.Add('Select max(ID) as ID from Classi');
Responder
Clique aqui para fazer login e interagir na Comunidade :)