In the code below, I'm setting a watch on the variable dbCon. When I expand
the watch on dbCon, one of the visible items under dbCon is "ServerVersion."
When the dbCon.Close() executes, I see the following:
dbCon.ServerVersion threw an expection of type
'System.InvalidOperationException'
....and the details...
Operation is not valid due to the current state of the object.
I'd rather not throw exceptions. Any ideas what I need to do before closing
to avoid all this?
Thanks...
DbConnection dbCon = null;
dbCon = db.CreateConnection();
dbCon.ConnectionString = DBConstants.ConnectionString(dbCon.ConnectionStrin g);
dbCon.Open();
adpt.SelectCommand = dbCmd;
adpt.SelectCommand.Connection = dbCon;
adpt.Fill(result);
dbCon.Close(); 4 2929
On Jun 24, 12:37*pm, rbDeveloper
<rbDevelo...@discussions.microsoft.comwrote:
In the code below, I'm setting a watch on the variable dbCon. When I expand
the watch on dbCon, one of the visible items under dbCon is "ServerVersion."
When the dbCon.Close() executes, I see the following:
dbCon.ServerVersion threw an expection of type
'System.InvalidOperationException'
...and the details...
Operation is not valid due to the current state of the object.
I'd rather not throw exceptions. Any ideas what I need to do before closing
to avoid all this?
You need to copy the value BEFORE closing the connection, if the
conenction is close you cannot access it
In this question, I'm actually all set with the data. The thing I'm trying to
figure out is what I need to do so that I don't get an exception when I call
dbCon.Close().
"Ignacio Machin ( .NET/ C# MVP )" wrote:
On Jun 24, 12:37 pm, rbDeveloper
<rbDevelo...@discussions.microsoft.comwrote:
In the code below, I'm setting a watch on the variable dbCon. When I expand
the watch on dbCon, one of the visible items under dbCon is "ServerVersion."
When the dbCon.Close() executes, I see the following:
dbCon.ServerVersion threw an expection of type
'System.InvalidOperationException'
...and the details...
Operation is not valid due to the current state of the object.
I'd rather not throw exceptions. Any ideas what I need to do before closing
to avoid all this?
You need to copy the value BEFORE closing the connection, if the
conenction is close you cannot access it
If you're looking at the watch you created earlier and see it doing that -
it's normal. When the properties are being checked by the watch you created,
and an exception gets thrown while it's updating the watch it just shows you
there was a problem. Those exceptions won't get thrown within your
application unless you access the dbCon.ServerVersion property after you've
closed the connection in your own code.
"rbDeveloper" <rb*********@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
In this question, I'm actually all set with the data. The thing I'm trying
to
figure out is what I need to do so that I don't get an exception when I
call
dbCon.Close().
"Ignacio Machin ( .NET/ C# MVP )" wrote:
>On Jun 24, 12:37 pm, rbDeveloper <rbDevelo...@discussions.microsoft.comwrote:
In the code below, I'm setting a watch on the variable dbCon. When I
expand
the watch on dbCon, one of the visible items under dbCon is
"ServerVersion."
When the dbCon.Close() executes, I see the following:
dbCon.ServerVersion threw an expection of type
'System.InvalidOperationException'
...and the details...
Operation is not valid due to the current state of the object.
I'd rather not throw exceptions. Any ideas what I need to do before
closing
to avoid all this?
You need to copy the value BEFORE closing the connection, if the conenction is close you cannot access it
Thanks!
"Jeff Winn" wrote:
If you're looking at the watch you created earlier and see it doing that -
it's normal. When the properties are being checked by the watch you created,
and an exception gets thrown while it's updating the watch it just shows you
there was a problem. Those exceptions won't get thrown within your
application unless you access the dbCon.ServerVersion property after you've
closed the connection in your own code.
"rbDeveloper" <rb*********@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
In this question, I'm actually all set with the data. The thing I'm trying
to
figure out is what I need to do so that I don't get an exception when I
call
dbCon.Close().
"Ignacio Machin ( .NET/ C# MVP )" wrote:
On Jun 24, 12:37 pm, rbDeveloper
<rbDevelo...@discussions.microsoft.comwrote:
In the code below, I'm setting a watch on the variable dbCon. When I
expand
the watch on dbCon, one of the visible items under dbCon is
"ServerVersion."
When the dbCon.Close() executes, I see the following:
dbCon.ServerVersion threw an expection of type
'System.InvalidOperationException'
...and the details...
Operation is not valid due to the current state of the object.
I'd rather not throw exceptions. Any ideas what I need to do before
closing
to avoid all this?
You need to copy the value BEFORE closing the connection, if the
conenction is close you cannot access it This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: clu82 |
last post by:
I have an MDI app that allows the user to open multiple client address child
forms. The user has a child form open that has client id "1001" and the
records associated data displayed. If the user...
|
by: Farooq Khan |
last post by:
i'm writing a class library having following code snippet. i want this class
to report an error (by throwing an Exception) to the application using this
class library. the problem is that within...
|
by: Kevin Yu |
last post by:
is it a bad programming design to throw exception in the try block then
catch it??
|
by: KJ |
last post by:
This is kind of hard to explain but I have a The
controls are created with CreateChildControls(). Now let say I click a
button and an error occurs in the control. If I throw it up it goes
back...
|
by: Sek |
last post by:
Hi Folks!
I was pondering over a code and noticed that exception handlers were
present in the private, protected as well as public methods. And,
ofcourse, public methods were calling priv/prot...
|
by: usenet |
last post by:
I wrote some sample code (see below) for nested exception throwing
i.e. my catch blocks are throwing exceptions of their own (for
simplicity I used standard exceptions). I am getting some...
|
by: =?Utf-8?B?VHJlY2l1cw==?= |
last post by:
Hello, Newsgroupians:
I am creating a wrapper for (I)DbConnection. I can connect to a database
and place queries; however, I'm having some problems with my wrapped class.
In short, I have the...
|
by: jobs |
last post by:
re: try catch finally to close and dispose, but still want
Application_error to fire
1. If catch an exception to to dispose and close of a ado connect, how
can I allow the exception to still...
|
by: =?Utf-8?B?VHJlY2l1cw==?= |
last post by:
Hello, Newsgroupians:
I've created a class that wraps DbConnection.
public class CSQL
{
protected System.Data.Common.DbConnection m_conn;
public CSQL
{
|
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: 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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |