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. 3 5166 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/
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: n_o_s_p_a__m |
last post by:
Can't compile. Does this mean that all functions that throw exceptions
must be of return type void?
examples:
// won't compile: "not all code paths return a value"
public override int Run() {...
|
by: Kepler |
last post by:
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...
|
by: SteadySteps |
last post by:
Hi
I migrated a project which compiles correctly on VC 6.0 to VS 2002. However
now all I get several warning that all the statements within catch blocks
are "unreachable code". How can I correct...
|
by: Hovik Melikyan |
last post by:
This code produces a 'unreachable code' warning at line 16 (throw new X ...)
with no visible reason:
#include <string>
class X
{
std::string msg;
|
by: dfetrow410 |
last post by:
Can I do this in an if statement?
public string getClass()
{
counta = counta + 1;
if (counta < 2 )
{
|
by: teddysnips |
last post by:
I'm new to C# - recent background mainly ASP.NET with VB.NET.
Anyhoot, I needed to create a C# statement analogous to VB's IIf:
VB.NET
Dim e As Boolean
e = IIf((CInt(MyVariable) 0), True,...
|
by: ev |
last post by:
Hello,
We are looking for any testing tool that is capable of checking code
coverage for C,C ++ and Java code. Or at least for C and C++. We want
to know how much (percentage) of our code written...
|
by: EmilyA |
last post by:
Hi! I'm not that good at programming, so I was wondering if anyone could tell me why I'm getting an unreachable statement error for lines 18, 35, 68, and 86.
import java.util.ArrayList;
...
|
by: HillBilly |
last post by:
What does that error mean and why would each break statement be marked as
unreachable? It implies the return will --always-- return some --thing-- if
even null and no further processing can...
|
by: premMS143 |
last post by:
Hi,
I want to ping certain systems IP. Everytime I'm using DOS or Start --> Run mode for pinging different PCs. But its becoming very difficult.
So I planned to develop a VB application to make...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |