If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Try catch Block

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-11-03, 13:32
marge marge is offline
Registered User
 
Join Date: Dec 2003
Posts: 1
Try catch Block

Hello,
Beginner here with a basic question
When do you use a Try and catch block in a program?Do you have to use try catch to make your pgm look more professional ?
Reply With Quote
  #2 (permalink)  
Old 12-12-03, 00:19
sendtovasu sendtovasu is offline
Registered User
 
Join Date: Dec 2003
Location: chennai
Posts: 27
Post Re: Try catch Block

try catch block is used to avoid termination of program in the runtime
try catch block is mainly used for database application
its nice way to use database application b'coz if any automatic or any runtime error causes termination of a program then there might be chances of crash in the databases

so if any error raised means we can catch in catch block and we can close the database in the catch block


Quote:
Originally posted by marge
Hello,
Beginner here with a basic question
When do you use a Try and catch block in a program?Do you have to use try catch to make your pgm look more professional ?
Reply With Quote
  #3 (permalink)  
Old 12-12-03, 01:34
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Actually try-catch-finally block is used to catch any errors/exceptions. It prevents your application from terminating unexpectedly and allows you to handle the errors.
Reply With Quote
  #4 (permalink)  
Old 12-17-03, 11:06
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
Quote:
Actually try-catch-finally block is used to catch any errors/exceptions. It prevents your application from terminating unexpectedly and allows you to handle the errors.
That's pretty much it in a nutshell. Another specific use not mentioned that I like to apply try..catch(try..except) blocks for is datatype checking. eg:

try
casttosomething(variable)
except
messagebox(invalid datatype, please enter a valid type)
end

Something like that checks to make sure a user input was a valid type, quite useful for data integrity.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On