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

Code after a Using statement is Unreachable?

P: n/a
I have a situation where I need to use a Using statement that creates
some records in a database. After that completes, if it completes, I
need to do some file creation. Any code I'm putting after the Using
statement gives a compiler warning of "Unreachable Code Detected", and
it never runs.

Why is this happening? I really don't want to put the file
manipulation code in the using statement because it's a transaction.
I also need for that code to occur after the aforementioned
transaction. To move it into the calling code would be really ugly,
since it belongs right within this function.

Any help will be appreciated.
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
fe***********@hotmail.com (Kepler) wrote in
news:35**************************@posting.google.c om:
I have a situation where I need to use a Using statement that
creates some records in a database. After that completes, if it
completes, I need to do some file creation. Any code I'm
putting after the Using statement gives a compiler warning of
"Unreachable Code Detected", and it never runs.

Why is this happening? I really don't want to put the file
manipulation code in the using statement because it's a
transaction. I also need for that code to occur after the
aforementioned transaction. To move it into the calling code
would be really ugly, since it belongs right within this
function.


Without seeing the actual code, my best guess is there is an
unconditional "return" or "throw" statement in the using block. The
compiler sees this and issues the warning, since the code after
either one of those statements will never be executed.

Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #2

P: n/a
Kepler <fe***********@hotmail.com> wrote:
I have a situation where I need to use a Using statement that creates
some records in a database. After that completes, if it completes, I
need to do some file creation. Any code I'm putting after the Using
statement gives a compiler warning of "Unreachable Code Detected", and
it never runs.

Why is this happening? I really don't want to put the file
manipulation code in the using statement because it's a transaction.
I also need for that code to occur after the aforementioned
transaction. To move it into the calling code would be really ugly,
since it belongs right within this function.


Please post the code - without seeing it, we can't know what's going
on.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

P: n/a
Kepler <fe***********@hotmail.com> wrote:
I have a situation where I need to use a Using statement that creates
some records in a database. After that completes, if it completes, I
need to do some file creation. Any code I'm putting after the Using
statement gives a compiler warning of "Unreachable Code Detected", and
it never runs.

Why is this happening? I really don't want to put the file
manipulation code in the using statement because it's a transaction.
I also need for that code to occur after the aforementioned
transaction. To move it into the calling code would be really ugly,
since it belongs right within this function.


Please post the code - without seeing it, we can't know what's going
on.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.