By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,536 Members | 2,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,536 IT Pros & Developers. It's quick & easy.

C# -App : "Unreachable code detected" warning When tyring to close connection to Data

P: 6
Hi, anyone please help me

when I try to close a connection to the database from a static method, "Unreachable code detected" error occured.

What's the problem actually?
Thank you before
Sep 29 '07 #1
Share this Question
Share on Google+
3 Replies


kenobewan
Expert 2.5K+
P: 4,871
Please show us the code so we can see why it was unreachable. Thanks.
Sep 29 '07 #2

Shashi Sadasivan
Expert 100+
P: 1,435
Hi, anyone please help me

when I try to close a connection to the database from a static method, "Unreachable code detected" error occured.

What's the problem actually?
Thank you before
Make sure there is a return value at the end.
Most probably you would be returning a value in a conditional statement but did not do it if that condition was false.

A good way is to post a sample of your code so that any errors noticable can be pointed out soon. Or you would end up decyphering it yourself.

cheers
Sep 29 '07 #3

P: 6
cie
Well anyway thanks for the reply but finally fixed it when I use try - catch - finally blocks. I put the code to close the connection in finally block.

:D
Oct 1 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.