0
I have a state register, which has a country. It registers normal, only that error occurs when accessing the state change.
I don’t know if it’s right, but from what I understand, something from the country is coming empty. How do I fix it. I’m not getting.
The architecture I’m using is MVC. and I’m programming in Delphi.
In my system, all records that have other records, this error occurs. So much so that in the city register, I can’t even add the state because this same error occurs, but speaking of the state.
DAO ESTADOS:
function daoEstados.carregar(pObj: TObject): string;
var mEstado : Estados; mPais : Paises;
begin
mEstado:= Estados( pObj );
mPais:= mEstado.getoPais;
mEstado.setCodigo( aDM.QEstados.FieldByName('CODESTADO').Value );
mEstado.setEstado( aDM.QEstados.FieldByName('ESTADO').AsString );
mEstado.setUF( aDM.QEstados.FieldByName('UF').AsString );
mPais.setCodigo( aDM.QEstados.FieldByName('CODPAIS').Value );
mPais.setPais( aDM.QPaises.FieldByName('PAIS').AsString );
mPais.setDDI( aDM.QPaises.FieldByName('DDI').AsString );
mPais.setSigla( aDM.QPaises.FieldByName('SIGLA').AsString );
mEstado.setDataCad( aDM.QEstados.FieldByName('DATACAD').AsDateTime );
end;
At CONTROLLER STATES:
function ctrlEstados.carregar(pObj: TObject): string;
var mPais : Paises; AFilter: TFilterSearch; tipoConsulta : TTipoConsulta;
begin
aDaoEstados.carregar( pObj );
mPais:= Estados( pObj ).getoPais;
aCtrlPaises.pesquisar(AFilter, IntToStr(mPais.getCodigo));
aCtrlPaises.carregar( oEstado.getoPais );
end;
She calls the research method the controller country, which calls the dao:
msql:= '';
case AFilter.TipoConsulta of
TpCCodigo:
begin
msql:= 'SELECT * FROM PAISES WHERE CODPAIS =' + IntToStr(
AFilter.Codigo );
end;
TpCParam:
begin
msql:= ( 'SELECT * FROM PAISES WHERE PAIS LIKE ' + QuotedStr(
'%' + AFilter.Parametro + '%' ) );
end;
TpCDDI:
begin
msql:= ( 'SELECT * FROM PAISES WHERE DDI LIKE ' + QuotedStr(
'%' + AFilter.DDI + '%' ) );
end;
TpCMoeda:
begin
msql:= ( 'SELECT * FROM PAISES WHERE MOEDA LIKE ' + QuotedStr(
'%' + AFilter.Moeda + '%' ) );
end;
TpCTODOS:
begin
msql:= 'SELECT * FROM PAISES ORDER BY CODPAIS';
end;
end;
aDM.QPaises.Active:= false;
aDM.QPaises.SQL.Text:=msql;
aDM.QPaises.Open;
result:= '';
In this research method, I made a marry to know the type of filter that is selected for query.
Only when you get to that part:
aDM.QPaises.Open;
Is that the error occurs.
Which code when running generates this error?
– Clarck Maciel
There is an error in Dao País. HERE Adm.QPaises.Active:= false; Adm.QPaises.SQL.Text:=msql; Adm.QPaises.Open; -> HERE result:= ''; In Controller Status you have this method: Function ctrlStated.load(pobj: Tobject): string; var mPais : Countries; Affiliate: Tfiltersearch; tipoConsulta : TTipoConsulta;
begin
 aDaoEstados.carregar( pObj );
 mPais:= Estados( pObj ).getoPais;
 aCtrlPaises.pesquisar(AFilter, IntToStr(mPais.getCodigo));
 aCtrlPaises.carregar( oEstado.getoPais ); end; .
– priscylam