Ola! estou tentao fazer uma consulta no banco de dados erretona o erro
“Dynamic SQL error SQL error code = -104”
procedure TImportXML.AdvGlowButton4Click(Sender: TObject);
begin
try
if ItemsCOD_LOCAL.AsString = ‘’ then
exit;
Application.CreateForm(TfrmCadproduto, FrmCadProduto);
if dm.IBTransaction.Active then
dm.IBTransaction.Commit;
dm.IBTransaction.StartTransaction;
dm.QProd.close;
dm.QProd.sql.Clear;
dm.QProd.sql.Text := sSql;
dm.QProd.sql.Add(' where COD_PRO=:COD');
dm.QProd.ParamByName('COD').AsInteger := ItemsCOD_LOCAL.AsInteger;
dm.QProd.Open;
with FrmCadProduto do
begin
FrmCadProduto.Tag := 1;
pc.ActivePageIndex := 0;
limpaedit(FrmCadProduto);
ededit(FrmCadProduto, false);
cod_pro.Text := dm.QProdCOD_PRO.AsString;
if trim(dm.QProdCONTROLA_ESTOQUE_PRO.AsString) = 'S' then
CheckControlaEstoque.Checked := true
else
CheckControlaEstoque.Checked := false;
EdtCodBarra.Text := dm.QProdCODIGO_BARRA_PRO.AsString;
edtnome.Text := dm.QProdNOME_PRO.AsString;
EdtDescCupom.Text := dm.QProdDESC_CUPOM.AsString;
cod_lab.Text := dm.QProdCOD_LAB.AsString;
edtnomelab.Text := dm.QProdNOME_LAB.AsString;
cod_sec.Text := dm.QProdCOD_SEC.AsString;
edtnomesec.Text := dm.QProdNOME_SEC.AsString;
EdtCodGrupo.Text := dm.QProdCOD_GRUPO.AsString;
EdtNomeGrupo.Text := dm.QProdDESCRICAO.AsString;
EdtCodSubGrupo.Text := dm.QProdSUB_GRUPO.AsString;
EdtNomeSubGrupo.Text := dm.QProdDESCRICAO1.Text;
edtvalor.Text := dm.QProdVALOR_PRO.AsString;
///edtpromocao.Text := dm.QProdPROMOCAO_PRO.AsString;
EdtComissao.Text := dm.QProdCOMISSAO_PRO.AsString;
EdtQuantEnt.Text := dm.QProdQUANT_UNIDADE_ENTRADA.AsString;
EdtEstMin.Text := dm.QProdESTOQUE_MINIMO_PRO.AsString;
EdtLoc.Text := dm.QProdLOCALIZACAO_PRO.AsString;
if trim(dm.QProdATIVO_PRO.AsString) = 'S' then
CheckAtivo.Checked := true
else
CheckAtivo.Checked := false;
EdtMargem.Text := dm.QProdMARGEM_LUCRO_PRO.AsString;
if dm.QProdPRODUTO_PESADO_PRO.AsString = 'N' then
ComboPeso.ItemIndex := 0
else if dm.QProdPRODUTO_PESADO_PRO.AsString = 'P' then
ComboPeso.ItemIndex := 1
else
ComboPeso.ItemIndex := 2;
cod_set.Text := dm.QProdCOD_SETOR.AsString;
EdtNomeSetor.Text := dm.QProdNOME_SET.AsString;
edttecla.Text := dm.QProdTECLA_ATALHO_PRO.AsString;
EdtCodReceita.Text := dm.QProdINDICE_RECEITA_PRO.AsString;
EdtDiasValidade.Text := dm.QProdDIAS_VALIDADE_PRO.AsString;
EdtRef.Text := dm.QProdREFERENCIA_PRO.AsString;
if trim(dm.QProdCOMPLEMENTO_PRO.AsString) = 'S' then
CheckComplemento.Checked := true
else
CheckComplemento.Checked := false;
EdtICMSContEst.Text := dm.QProdICMS_CONT_EST.AsString;
edticmsCFest.Text := dm.QProdICMS_CF_EST.AsString;
EdtICMSCONTFora.Text := dm.QProdICMS_CONT_FORA.AsString;
EdtICMSCFFora.Text := dm.QProdICMS_CF_FORA.AsString;
EdtCSTCONTEst.Text := dm.QProdCST_CONT_EST.AsString;
EdtCSTCONTFora.Text := dm.QProdCST_CONT_FORA.AsString;
EdtCSTCFEst.Text := dm.QProdCST_CF_EST.AsString;
EdtCSTCFFora.Text := dm.QProdCST_CF_FORA.AsString;
EdtCFOPVEstCONT.Text := dm.QProdCFOP_VENDAS_CONT_EST.AsString;
EdtCFOPVEstCF.Text := dm.QProdCFOP_VENDAS_CF_EST.AsString;
EdtCFOPVForaCONT.Text := dm.QProdCFOP_VENDAS_CONT_FORA.AsString;
EdtCFOPVForaCF.Text := dm.QProdCFOP_VENDAS_CF_FORA.AsString;
if dm.QProdSAIR_TABELA_PRECO.AsString = 'S' then
CheckTabela.Checked := true
else
CheckTabela.Checked := false;
if dm.QProdST_CONT_EST.AsString = 'S' then
CheckSTCONTEst.Checked := true
else
CheckSTCONTEst.Checked := false;
EdtVrAgregCONTEst.Text := dm.QProdVR_AGREG_CONT_EST.AsString;
EdtIPICONTEst.Text := dm.QProdIPI_CONT_EST.AsString;
EdtIPICFEst.Text := dm.QProdIPI_CF_EST.AsString;
EdtIPICONTFora.Text := dm.QProdIPI_CONT_FORA.AsString;
EdtIPICFFora.Text := dm.QProdIPI_CF_FORA.AsString;
EdtBCRCONTEst.Text := dm.QProdRED_CONT_EST.AsString;
EdtBCRCFEst.Text := dm.QProdRED_CF_EST.AsString;
EdtBCRCONTFora.Text := dm.QProdRED_CONT_FORA.AsString;
EdtBCRCFFora.Text := dm.QProdRED_CF_FORA.AsString;
EdtNCM.Text := dm.QProdCOD_NCM.AsString;
EdtProdEstoque.Text := dm.QProdCOD_PRODUTO_ESTOQUE.AsString;
ComboTipo.ItemIndex := dm.QProdCODIGO_TIPO.AsInteger - 1;
EdtAliqPis.Text := dm.QProdALIQUOTA_PIS.AsString;
EdtAliqCofins.Text := dm.QProdALIQUOTA_COFINS.AsString;
EdtAliqIR.Text := dm.QProdALIQUOTA_IR.AsString;
EdtAliqCSLL.Text := dm.QProdALIQUOTA_CSLL.AsString;
EdtAliqOutras.Text := dm.QProdALIQUOTA_OUTRAS.AsString;
EdtVarejoPrazo.Text := dm.QProdPRECO_PRAZO_PRO.AsString;
if trim(dm.QProdTIPO_PRODUCAO.AsString) = 'P' then
ComboTipoProducao.ItemIndex := 0
else
ComboTipoProducao.ItemIndex := 1;
if trim(dm.QProdISENTO_PIS_COFINS_PRO.AsString) = 'S' then
CheckPisCofins.Checked := true
else
CheckPisCofins.Checked := false;
EdtCodUndEntrada.Text := dm.QProdCODIGO_UNIDADE_ENTRADA.AsString;
EdtCodundSaida.Text := dm.QProdCODIGO_UNIDADE_SAIDA.AsString;
EdtNomeUndEntrada.Text := dm.QProdUND_ENTRADA.AsString;
EdtNomeUndSaida.Text := dm.QProdUND_SAIDA.AsString;
if dm.QProdDATA_VALIDADE.IsNull then
EdtDataValidade.Clear
else
EdtDataValidade.Text := dm.QProdDATA_VALIDADE.AsString;
EdtCodSetorEstoque.Text := dm.QProdCODIGO_SETOR_ESTOQUE.AsString;
EdtNomeSetorEstoque.Text := dm.QProdSETOR_ESTOQUE.AsString;
EdtORIG.Text := dm.QProdORIG.AsString;
EdtCSOSN.Text := dm.QProdCSOSN.AsString;
edtTamanho.Text := trim(dm.QProdTAMANHO.AsString);
edtCor.Text := trim(dm.QProdCOR.AsString);
edtOBS.Lines.Text := (dm.QProdOBS.AsString);
CST_PIS.Text := trim(dm.Qprodcst_pis.AsString);
CST_COFINS.Text := trim(dm.Qprodcst_cofins.AsString);
edtCST_ipi.Text := trim(dm.qprodcst_ipi.AsString);
if not dm.QProdCAMINHO_FOTO_PRO.IsNull then
begin
OpenPicture.FileName := dm.QProdCAMINHO_FOTO_PRO.Value;
image.Visible := true;
try
image.Picture.LoadFromFile(dm.QProdCAMINHO_FOTO_PRO.Value);
except
image.Picture := nil
end;
end
else
begin
OpenPicture.FileName := '';
image.Visible := false;
end;
dm.QProd.close;
dm.QProd.sql.Text := sSql;
dm.IBTransaction.Commit;
FormShow(FrmCadProduto);
showmodal;
if dm.IBTransaction.Active then
dm.IBTransaction.Commit;
dm.IBTransaction.StartTransaction;
dm.QProd.close;
dm.QProd.sql.Clear;
dm.QProd.sql.Text := sSql;
dm.QProd.sql.Add(' where COD_PRO=:COD');
dm.QProd.ParamByName('COD').AsInteger := ItemsCOD_LOCAL.AsInteger;
dm.QProd.Open;
Items.Edit;
ItemsQUANT_ENT.AsCurrency := dm.QProdQUANT_UNIDADE_ENTRADA.AsCurrency;
Items.Post;
dm.IBTransaction.Commit;
end;
except
on E: Exception do
begin
dm.QProd.close;
dm.QProd.sql.Text := sSql;
dm.IBTransaction.Rollback;
ShowMessage(‘Erro ao abrir produto’ + #13 + E.Message);
end;
end;
end;