Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 432
  • Last Modified:

aborting connection in TSQLConnections OnBeforeConnect event

I want to abort TSQLConnection from connecting to the DB in OnBeforeConnection event, but i get EAbort exception and after that runtime errors and my program is terminated.

i have the following code:

procedure TDataModule1.SQLConnectionBeforeConnect(Sender: TObject);
begin
  if (not RunTimeConnection) then Abort;
end; // part of the tutorial at http://delphi.about.com/od/database/a/db_connection.htm

so i wonder how can i tell TSQLConnection not to conect in OnBeforeConnect event.

Thanks in advance

0
kzdown
Asked:
kzdown
  • 4
  • 3
  • 2
  • +2
1 Solution
 
mikelittlewoodCommented:
Try using sysUtils.abort
0
 
kzdownAuthor Commented:
Unfortunatly i still get the same error msgs
0
 
kretzschmarCommented:
this bahaviour is
within the ide or also outside the ide
??

meikl ;-)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
kzdownAuthor Commented:
both.
everything i tried failed. I cant cancel/abort connection in OnBeforeConnect event :(
0
 
kretzschmarCommented:
hmm,

maybe you should catch the exception like

try
  SQLConnection1.open;
except
  //nothing or a message
end;

meikl ;-)
0
 
kzdownAuthor Commented:
the problem is that if i try to connect it waits 30 secs and freezes my application till i get error that i cant connect. thats why i need some smarter way and i followed tutorial http://delphi.about.com/od/database/a/db_connection.htm but this single issue doesnt allow me to abort connection.
0
 
CodedKCommented:
Try AnyDAC components.
Check the properties and decrease the wait time to 5 seconds.
0
 
RuntimeError007Commented:
Have you tried something like this:


If SQLConnection1.open then SQLConnection1.Close; ? or do you still get the error there?

If yes, there might be a problem with the connection itself and because of this the OnBeforeConnect event code is not responding as it should.



0
 
kzdownAuthor Commented:
RuntimeError007:
the idea is to avoid calling open method.
0
 
CodedKCommented:
Kzdown AnyDAC offers automatic recovery of broken connection :
See at the bottom ofthis page :
http://www.da-soft.com/content/view/113/206/#v1vsv2
0
 
CodedKCommented:
Check the "AnyDAC_Architecture.pdf" in this download ....
http://www.da-soft.com/component/option,com_docman/task,doc_download/gid,8/Itemid,90/


Scroll down to Error Handling. (Page 15).
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now