Objeto Parameter definido incorretamente. As informações são inconsistentes ou incompletas

21/05/2020

0

Objeto Parameter definido incorretamente. As informações são inconsistentes ou incompletas
isso acontece aonde eu passo o valor á algum parametro

with ADO_Funcionario, SQL do
begin
Clear;
Close;
Add('select a.nome, a.COD_PESSOA, a.MATRICULA,C.CodigoDeBarras, CAST(b.DataHora as datetime) data_acesso ');
Add('from [TopAcesso].[dbo].[Funcionarios] a, ');
Add(' [TopAcesso].[dbo].[Bilhetes] b, ');
Add(' [TopAcesso].[dbo].[Cartoes] c ');
Add('where a.COD_PESSOA = b.COD_PESSOA AND A.COD_PESSOA = C.COD_PESSOA ');
Add('and b.Tipo = 10 ');

if CB_Inners.ItemIndex > 0 then
Add(' and b.NumInner = :winner ');

if CB_perfilacesso.ItemIndex > 0 then
Add(' and a.COD_PERFIL = :wperfil ');

if cb_Departamentos.ItemIndex > 0 then
Add(' and a.COD_DEPARTAMENTO = :wdepartamento ');

if Edit_NOME.Text <> '' then
begin
Add(' and (UPPER(a.nome)) like :wnome ');
end;

if ((Copy(CB_Departamentos.Text,1,2) = '00') OR (Copy(CB_Departamentos.Text,1,2) = '**')) then
begin
// INI VISITANTES
Add(' UNION all ');

Add(' select x.nome, x.COD_PESSOA, x.DOCUMENTO, '''+'Visitante'+''', CAST(y.DataHora as date) data_acesso ');
Add(' from [TopAcesso].[dbo].[Visitantes] x, ');
Add(' [TopAcesso].[dbo].[Bilhetes] y ');
Add(' where x.COD_PESSOA = y.COD_PESSOA ');
Add(' and y.Tipo = 10 ');

end;

if CB_Inners.ItemIndex > 0 then
Add(' and Y.NumInner = :winner ');

if CB_perfilacesso.ItemIndex > 0 then
Add(' and X.COD_PERFIL = :wperfil ');

if cb_Departamentos.ItemIndex > 0 then
Add(' and X.COD_DEPARTAMENTO = :wdepartamento ');

if Edit_NOME.Text <> '' then
begin
Add(' and (UPPER(X.nome)) like :wnome ');
end;


if CB_Inners.ItemIndex > 0 then
begin
iinner := StrToInt(Copy(CB_Inners.Text,1,2));
Parameters.ParamByName('winner').Value := iinner;
end;

if CB_perfilacesso.ItemIndex > 0 then
begin
iperfil := StrToInt(Copy(CB_perfilacesso.Text,1,2));
Parameters.ParamByName('wperfil').Value := iperfil;
end;

if CB_Departamentos.ItemIndex > 0 then
begin
departamento := StrToInt(Copy(CB_Departamentos.Text,1,2));
Parameters.ParamByName('wdepartamento').Value := departamento;
end;

Open;
Lucas

Lucas

Responder

Posts

22/05/2020

Emerson Nascimento

a criação dos parâmetros do visitante precisam ficar dentro do if.. do visitante.
with ADO_Funcionario, SQL do
begin
	Close;
	Clear;
	Add('select a.nome, a.COD_PESSOA, a.MATRICULA,C.CodigoDeBarras, CAST(b.DataHora as datetime) data_acesso ');
	Add('from [TopAcesso].[dbo].[Funcionarios] a, ');
	Add(' [TopAcesso].[dbo].[Bilhetes] b, ');
	Add(' [TopAcesso].[dbo].[Cartoes] c ');
	Add('where a.COD_PESSOA = b.COD_PESSOA AND A.COD_PESSOA = C.COD_PESSOA ');
	Add('and b.Tipo = 10 ');

	if CB_Inners.ItemIndex > 0 then
		Add(' and b.NumInner = :winner ');

	if CB_perfilacesso.ItemIndex > 0 then
		Add(' and a.COD_PERFIL = :wperfil ');

	if cb_Departamentos.ItemIndex > 0 then
		Add(' and a.COD_DEPARTAMENTO = :wdepartamento ');

	if Edit_NOME.Text <> '' then
		Add(' and (UPPER(a.nome)) like :wnome ');

	if ((Copy(CB_Departamentos.Text,1,2) = '00') OR (Copy(CB_Departamentos.Text,1,2) = '**')) then
	begin
		// INI VISITANTES
		Add(' UNION all ');

		Add(' select x.nome, x.COD_PESSOA, x.DOCUMENTO, '''+'Visitante'+''', CAST(y.DataHora as date) data_acesso ');
		Add(' from [TopAcesso].[dbo].[Visitantes] x, ');
		Add(' [TopAcesso].[dbo].[Bilhetes] y ');
		Add(' where x.COD_PESSOA = y.COD_PESSOA ');
		Add(' and y.Tipo = 10 ');

		if CB_Inners.ItemIndex > 0 then
			Add(' and Y.NumInner = :winner ');

		if CB_perfilacesso.ItemIndex > 0 then
			Add(' and X.COD_PERFIL = :wperfil ');

		if cb_Departamentos.ItemIndex > 0 then
			Add(' and X.COD_DEPARTAMENTO = :wdepartamento ');

		if Edit_NOME.Text <> '' then
			Add(' and (UPPER(X.nome)) like :wnome ');
	end;

	if CB_Inners.ItemIndex > 0 then
		Parameters.ParamByName('winner').Value := StrToInt(Copy(CB_Inners.Text,1,2));

	if CB_perfilacesso.ItemIndex > 0 then
		Parameters.ParamByName('wperfil').Value := StrToInt(Copy(CB_perfilacesso.Text,1,2));

	if CB_Departamentos.ItemIndex > 0 then
		Parameters.ParamByName('wdepartamento').Value := StrToInt(Copy(CB_Departamentos.Text,1,2));

	Open;
Responder

25/05/2020

Lucas

a criação dos parâmetros do visitante precisam ficar dentro do if.. do visitante.
with ADO_Funcionario, SQL do
begin
	Close;
	Clear;
	Add('select a.nome, a.COD_PESSOA, a.MATRICULA,C.CodigoDeBarras, CAST(b.DataHora as datetime) data_acesso ');
	Add('from [TopAcesso].[dbo].[Funcionarios] a, ');
	Add(' [TopAcesso].[dbo].[Bilhetes] b, ');
	Add(' [TopAcesso].[dbo].[Cartoes] c ');
	Add('where a.COD_PESSOA = b.COD_PESSOA AND A.COD_PESSOA = C.COD_PESSOA ');
	Add('and b.Tipo = 10 ');

	if CB_Inners.ItemIndex > 0 then
		Add(' and b.NumInner = :winner ');

	if CB_perfilacesso.ItemIndex > 0 then
		Add(' and a.COD_PERFIL = :wperfil ');

	if cb_Departamentos.ItemIndex > 0 then
		Add(' and a.COD_DEPARTAMENTO = :wdepartamento ');

	if Edit_NOME.Text <> '' then
		Add(' and (UPPER(a.nome)) like :wnome ');

	if ((Copy(CB_Departamentos.Text,1,2) = '00') OR (Copy(CB_Departamentos.Text,1,2) = '**')) then
	begin
		// INI VISITANTES
		Add(' UNION all ');

		Add(' select x.nome, x.COD_PESSOA, x.DOCUMENTO, '''+'Visitante'+''', CAST(y.DataHora as date) data_acesso ');
		Add(' from [TopAcesso].[dbo].[Visitantes] x, ');
		Add(' [TopAcesso].[dbo].[Bilhetes] y ');
		Add(' where x.COD_PESSOA = y.COD_PESSOA ');
		Add(' and y.Tipo = 10 ');

		if CB_Inners.ItemIndex > 0 then
			Add(' and Y.NumInner = :winner ');

		if CB_perfilacesso.ItemIndex > 0 then
			Add(' and X.COD_PERFIL = :wperfil ');

		if cb_Departamentos.ItemIndex > 0 then
			Add(' and X.COD_DEPARTAMENTO = :wdepartamento ');

		if Edit_NOME.Text <> '' then
			Add(' and (UPPER(X.nome)) like :wnome ');
	end;

	if CB_Inners.ItemIndex > 0 then
		Parameters.ParamByName('winner').Value := StrToInt(Copy(CB_Inners.Text,1,2));

	if CB_perfilacesso.ItemIndex > 0 then
		Parameters.ParamByName('wperfil').Value := StrToInt(Copy(CB_perfilacesso.Text,1,2));

	if CB_Departamentos.ItemIndex > 0 then
		Parameters.ParamByName('wdepartamento').Value := StrToInt(Copy(CB_Departamentos.Text,1,2));

	Open;

ainda esta aparecendo este erro
Responder

25/05/2020

Emerson Nascimento

acredito que esteja faltando
    if Edit_NOME.Text <> '' then
        Parameters.ParamByName('wnome ').AsString := Edit_NOME.Text;


código completo:
with ADO_Funcionario, SQL do
begin
    Close;
    Clear;
    Add('select a.nome, a.COD_PESSOA, a.MATRICULA,C.CodigoDeBarras, CAST(b.DataHora as datetime) data_acesso ');
    Add('from [TopAcesso].[dbo].[Funcionarios] a, ');
    Add(' [TopAcesso].[dbo].[Bilhetes] b, ');
    Add(' [TopAcesso].[dbo].[Cartoes] c ');
    Add('where a.COD_PESSOA = b.COD_PESSOA AND A.COD_PESSOA = C.COD_PESSOA ');
    Add('and b.Tipo = 10 ');
 
    if CB_Inners.ItemIndex > 0 then
        Add(' and b.NumInner = :winner ');
 
    if CB_perfilacesso.ItemIndex > 0 then
        Add(' and a.COD_PERFIL = :wperfil ');
 
    if cb_Departamentos.ItemIndex > 0 then
        Add(' and a.COD_DEPARTAMENTO = :wdepartamento ');
 
    if Edit_NOME.Text <> '' then
        Add(' and (UPPER(a.nome)) like :wnome ');
 
    if ((Copy(CB_Departamentos.Text,1,2) = '00') OR (Copy(CB_Departamentos.Text,1,2) = '**')) then
    begin
        // INI VISITANTES
        Add(' UNION all ');
 
        Add(' select x.nome, x.COD_PESSOA, x.DOCUMENTO, '''+'Visitante'+''', CAST(y.DataHora as date) data_acesso ');
        Add(' from [TopAcesso].[dbo].[Visitantes] x, ');
        Add(' [TopAcesso].[dbo].[Bilhetes] y ');
        Add(' where x.COD_PESSOA = y.COD_PESSOA ');
        Add(' and y.Tipo = 10 ');
 
        if CB_Inners.ItemIndex > 0 then
            Add(' and Y.NumInner = :winner ');
 
        if CB_perfilacesso.ItemIndex > 0 then
            Add(' and X.COD_PERFIL = :wperfil ');
 
        if cb_Departamentos.ItemIndex > 0 then
            Add(' and X.COD_DEPARTAMENTO = :wdepartamento ');
 
        if Edit_NOME.Text <> '' then
            Add(' and (UPPER(X.nome)) like :wnome ');
    end;
 
    if CB_Inners.ItemIndex > 0 then
        Parameters.ParamByName('winner').AsInteger := StrToInt(Copy(CB_Inners.Text,1,2));
 
    if CB_perfilacesso.ItemIndex > 0 then
        Parameters.ParamByName('wperfil').AsInteger := StrToInt(Copy(CB_perfilacesso.Text,1,2));
 
    if CB_Departamentos.ItemIndex > 0 then
        Parameters.ParamByName('wdepartamento').AsInteger := StrToInt(Copy(CB_Departamentos.Text,1,2));
 
    if Edit_NOME.Text <> '' then
        Parameters.ParamByName('wnome').AsString := '%'+Trim(Edit_NOME.Text)+'%';

    Open;

Responder

26/05/2020

Lucas

acredito que esteja faltando
    if Edit_NOME.Text <> '' then
        Parameters.ParamByName('wnome ').AsString := Edit_NOME.Text;


código completo:
with ADO_Funcionario, SQL do
begin
    Close;
    Clear;
    Add('select a.nome, a.COD_PESSOA, a.MATRICULA,C.CodigoDeBarras, CAST(b.DataHora as datetime) data_acesso ');
    Add('from [TopAcesso].[dbo].[Funcionarios] a, ');
    Add(' [TopAcesso].[dbo].[Bilhetes] b, ');
    Add(' [TopAcesso].[dbo].[Cartoes] c ');
    Add('where a.COD_PESSOA = b.COD_PESSOA AND A.COD_PESSOA = C.COD_PESSOA ');
    Add('and b.Tipo = 10 ');
 
    if CB_Inners.ItemIndex > 0 then
        Add(' and b.NumInner = :winner ');
 
    if CB_perfilacesso.ItemIndex > 0 then
        Add(' and a.COD_PERFIL = :wperfil ');
 
    if cb_Departamentos.ItemIndex > 0 then
        Add(' and a.COD_DEPARTAMENTO = :wdepartamento ');
 
    if Edit_NOME.Text <> '' then
        Add(' and (UPPER(a.nome)) like :wnome ');
 
    if ((Copy(CB_Departamentos.Text,1,2) = '00') OR (Copy(CB_Departamentos.Text,1,2) = '**')) then
    begin
        // INI VISITANTES
        Add(' UNION all ');
 
        Add(' select x.nome, x.COD_PESSOA, x.DOCUMENTO, '''+'Visitante'+''', CAST(y.DataHora as date) data_acesso ');
        Add(' from [TopAcesso].[dbo].[Visitantes] x, ');
        Add(' [TopAcesso].[dbo].[Bilhetes] y ');
        Add(' where x.COD_PESSOA = y.COD_PESSOA ');
        Add(' and y.Tipo = 10 ');
 
        if CB_Inners.ItemIndex > 0 then
            Add(' and Y.NumInner = :winner ');
 
        if CB_perfilacesso.ItemIndex > 0 then
            Add(' and X.COD_PERFIL = :wperfil ');
 
        if cb_Departamentos.ItemIndex > 0 then
            Add(' and X.COD_DEPARTAMENTO = :wdepartamento ');
 
        if Edit_NOME.Text <> '' then
            Add(' and (UPPER(X.nome)) like :wnome ');
    end;
 
    if CB_Inners.ItemIndex > 0 then
        Parameters.ParamByName('winner').AsInteger := StrToInt(Copy(CB_Inners.Text,1,2));
 
    if CB_perfilacesso.ItemIndex > 0 then
        Parameters.ParamByName('wperfil').AsInteger := StrToInt(Copy(CB_perfilacesso.Text,1,2));
 
    if CB_Departamentos.ItemIndex > 0 then
        Parameters.ParamByName('wdepartamento').AsInteger := StrToInt(Copy(CB_Departamentos.Text,1,2));
 
    if Edit_NOME.Text <> '' then
        Parameters.ParamByName('wnome').AsString := '%'+Trim(Edit_NOME.Text)+'%';

    Open;


ainda continuya com esse erro
ele comecou qunado troquei o union para o union all
Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar