Hello,
I am having a problem with two tables linked by parameters, when I go to the last row, the second table doen't show the last register. I am gonna detail all the problems bellow.
My form has:
1 dbnavigator
2 dbgrid
2 TsqlQuery
2 TDataSetProvider
2 TClientDatase
2 TDataSource
The first TsqlQuery has this SQL query:
select a.codcad, b.nomcad, a.datped, a.numped, a.seqped from arfat a
inner join arcad b on (b.codcad=a.codcad)
The second TsqlQuery has this SQL query:
select a.codpro, b.nompro, a.numped, a.seqped, a.seq from arifat a
inner join arest b on (b.codpro=a.codpro)
where a.numped=:numped and a.seqped=:seqped
as you can see, I have two parameter in my second TSQLquery,
I linked all the components TSQLQuery -> TDataSetProvider -> TClientDatase -> TDataSource
My dbNavigator is connected with the FIRST DataSource. When I go to the last row in my dbgrid1, on the event afterScroll of DataSet1 I close and open the segund DataSet so that Can show the register linked throught the parameters as you can see in the second SQL query, but it doens't display the records. To solve the problem, I have to return one row and then go to the last again so that my dataset can display the rows linked with my dataset 1
I made the same test with Ado components and it worked very fine.
Please, I need this corrected as soon as possible once I am having many problems with my system on my costumers.
If you need, I can send you a simple project to be analised.
regards
Alexandre
Search found 7 matches
- Fri 26 Nov 2021 18:06
- Forum: dbExpress driver for SQL Server
- Topic: problem using two dataset linked through parameters.
- Replies: 4
- Views: 26263
- Thu 21 Mar 2019 11:20
- Forum: SecureBridge
- Topic: Rewrite the code to use the secureBridge
- Replies: 3
- Views: 3295
Re: Rewrite the code to use the secureBridge
Hello ViktorV,
First of all, I want to thank you for your help.
In your code there is function TEncoding.UTF8.GetBytes(PostStr) used,
where can I get this functin TEncoding.UTF8.GetBytes(PostStr) ? It seems there isn't it for delphi 2007.
regards
Alex
First of all, I want to thank you for your help.
In your code there is function TEncoding.UTF8.GetBytes(PostStr) used,
where can I get this functin TEncoding.UTF8.GetBytes(PostStr) ? It seems there isn't it for delphi 2007.
regards
Alex
- Tue 19 Mar 2019 11:57
- Forum: SecureBridge
- Topic: Rewrite the code to use the secureBridge
- Replies: 3
- Views: 3295
Rewrite the code to use the secureBridge
Hello,
I've bought the SecureBridge so that I could use Https in my application.
I am having difficulties to rewrite a small code where I could use the secureBridge, I am not sure the steps and if the correct component would it be the ScHttpWebRequest, I appreciate a lot your help with my small code:
Retry:= True;
Tries := 0;
while Retry do
begin
HTTPSend.Clear;
PostStr := 'cnpj='+OnlyNumber(ACNPJ)+'&' +
'origem=comprovante&' +
'search_type=cnpj&' +
'submit1=Consultar&' +
'txtTexto_captcha_serpro_gov_br='+Trim(ACaptcha);
WriteStrToStream( HTTPSend.Document, PostStr );
HTTPSend.MimeType := 'application/x-www-form-urlencoded';
HTTPSend.Cookies.Add('flag=1');
HTTPSend.Headers.Add('Referer: https://www.receita.fazenda.gov.br/pess ... tacao3.asp');
HTTPPost('https://www.receita.fazenda.gov.br/pess ... valida.asp');
Retry := (Tries < 2) and
(pos('Captcha Sonoro', RespHTTP.Text) > 0) and
(pos(ACBrStr('Digite o número de CNPJ da empresa e clique em'), RespHTTP.Text) > 0);
Inc( Tries );
end;
regards
Alexandre
I've bought the SecureBridge so that I could use Https in my application.
I am having difficulties to rewrite a small code where I could use the secureBridge, I am not sure the steps and if the correct component would it be the ScHttpWebRequest, I appreciate a lot your help with my small code:
Retry:= True;
Tries := 0;
while Retry do
begin
HTTPSend.Clear;
PostStr := 'cnpj='+OnlyNumber(ACNPJ)+'&' +
'origem=comprovante&' +
'search_type=cnpj&' +
'submit1=Consultar&' +
'txtTexto_captcha_serpro_gov_br='+Trim(ACaptcha);
WriteStrToStream( HTTPSend.Document, PostStr );
HTTPSend.MimeType := 'application/x-www-form-urlencoded';
HTTPSend.Cookies.Add('flag=1');
HTTPSend.Headers.Add('Referer: https://www.receita.fazenda.gov.br/pess ... tacao3.asp');
HTTPPost('https://www.receita.fazenda.gov.br/pess ... valida.asp');
Retry := (Tries < 2) and
(pos('Captcha Sonoro', RespHTTP.Text) > 0) and
(pos(ACBrStr('Digite o número de CNPJ da empresa e clique em'), RespHTTP.Text) > 0);
Inc( Tries );
end;
regards
Alexandre
- Tue 19 Mar 2019 11:49
- Forum: SecureBridge
- Topic: TScHttpWebResponse ReadAsBytes
- Replies: 12
- Views: 2223
Re: TScHttpWebResponse ReadAsBytes
Thanks very much for your help, it solved the problem
- Mon 18 Mar 2019 14:58
- Forum: SecureBridge
- Topic: TScHttpWebResponse ReadAsBytes
- Replies: 12
- Views: 2223
Re: TScHttpWebResponse ReadAsBytes
Hi,
I am using the latest version 9.02.
The version of my delphi is 2007, do you think that I am getting this error because of my delphi version?
I am using the latest version 9.02.
The version of my delphi is 2007, do you think that I am getting this error because of my delphi version?
- Mon 18 Mar 2019 12:45
- Forum: SecureBridge
- Topic: TScHttpWebResponse ReadAsBytes
- Replies: 12
- Views: 2223
Re: TScHttpWebResponse ReadAsBytes
Hello ViktorV,
I don't have my buf = nil, but I am having problem in this line:
Stream.Write(buf, Length(buf));
Please, try this code and see if you can load a jpeg into an img component.
procedure TF_Principal.Captcha3();
var
Request: TScHttpWebRequest;
Response: TScHttpWebResponse;
Buf: TBytes;
Stream: TMemoryStream;
JPG: TJPEGImage;
begin
JPG := TJPEGImage.Create;
Stream := TMemoryStream.Create;
Request := TScHttpWebRequest.Create('https://community.embarcadero.com/uploa ... lerNew.jpg');
try
Response := Request.GetResponse;
try
Buf := Response.ReadAsBytes;
if Buf<>nil then
Begin
Stream.Write(buf, Length(buf));
Stream.Position := 0;
JPG.LoadFromStream(Stream);
sImage1.Picture.Graphic := JPG;
End;
finally
Response.Free;
end;
finally
Request.Free;
Stream.Free;
JPG.Free;
end;
end;
Thanks
Alex
I don't have my buf = nil, but I am having problem in this line:
Stream.Write(buf, Length(buf));
Please, try this code and see if you can load a jpeg into an img component.
procedure TF_Principal.Captcha3();
var
Request: TScHttpWebRequest;
Response: TScHttpWebResponse;
Buf: TBytes;
Stream: TMemoryStream;
JPG: TJPEGImage;
begin
JPG := TJPEGImage.Create;
Stream := TMemoryStream.Create;
Request := TScHttpWebRequest.Create('https://community.embarcadero.com/uploa ... lerNew.jpg');
try
Response := Request.GetResponse;
try
Buf := Response.ReadAsBytes;
if Buf<>nil then
Begin
Stream.Write(buf, Length(buf));
Stream.Position := 0;
JPG.LoadFromStream(Stream);
sImage1.Picture.Graphic := JPG;
End;
finally
Response.Free;
end;
finally
Request.Free;
Stream.Free;
JPG.Free;
end;
end;
Thanks
Alex
- Fri 15 Mar 2019 16:54
- Forum: SecureBridge
- Topic: TScHttpWebResponse ReadAsBytes
- Replies: 12
- Views: 2223
Re: TScHttpWebResponse ReadAsBytes
Hello,
I have accompany this thread and I am very interested on it.
I have tried the code but I am getting an error, please take a look at the code:
procedure TF_Principal.Captcha2();
var
Request: TScHttpWebRequest;
Response: TScHttpWebResponse;
Buf: TBytes;
Stream: TMemoryStream;
Png : TPNGGraphic;
Request := TScHttpWebRequest.Create('https://www.receita.fazenda.gov.br/pess ... aptcha.asp');
try
Response := Request.GetResponse;
try
Stream:= TMemoryStream.Create;
Png := TPNGGraphic.create;
buf := Response.ReadAsBytes;
Stream.Write(buf, Length(buf));
Stream.Position := 0;
png.LoadFromStream( Stream );
sImage1.Picture.Assign(Png);
finally
Response.Free;
end;
finally
Request.Free;
Stream.Free;
end;
end;
I've also tried your example with this URL:
Request := TScHttpWebRequest.Create('https://community.embarcadero.com/uploa ... lerNew.jpg');
with the code above but I got the same error:
"Access violation at address 004031E3 in module 'ConsultaCNPJ.exe'. Read of address 00197D5C."
this error happens in this line:
Stream.Write(buf, Length(buf));
What could it be?
thanks a lot
regards
Alexandre / Brazil
I have accompany this thread and I am very interested on it.
I have tried the code but I am getting an error, please take a look at the code:
procedure TF_Principal.Captcha2();
var
Request: TScHttpWebRequest;
Response: TScHttpWebResponse;
Buf: TBytes;
Stream: TMemoryStream;
Png : TPNGGraphic;
Request := TScHttpWebRequest.Create('https://www.receita.fazenda.gov.br/pess ... aptcha.asp');
try
Response := Request.GetResponse;
try
Stream:= TMemoryStream.Create;
Png := TPNGGraphic.create;
buf := Response.ReadAsBytes;
Stream.Write(buf, Length(buf));
Stream.Position := 0;
png.LoadFromStream( Stream );
sImage1.Picture.Assign(Png);
finally
Response.Free;
end;
finally
Request.Free;
Stream.Free;
end;
end;
I've also tried your example with this URL:
Request := TScHttpWebRequest.Create('https://community.embarcadero.com/uploa ... lerNew.jpg');
with the code above but I got the same error:
"Access violation at address 004031E3 in module 'ConsultaCNPJ.exe'. Read of address 00197D5C."
this error happens in this line:
Stream.Write(buf, Length(buf));
What could it be?
thanks a lot
regards
Alexandre / Brazil