473,770 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sqldatareader not having a valid connection after db restarts?

cp
I have a business object (c#) running on an app server that talks to my sql server 2000 (2 separate physical machines). If sql server gets restarted (i.e. someone kicks the cord out of the wall on the db server and it needs to be restarted), the connections that IIS is maintaining seem to be invalid. If someone can verify that or explain a little about how the internals of that works, that would be educational for me but I'll take it on faith from the results of my tests. In order to recreate valid connections I have my ExecuteReader statement in a try/catch. If I call close and then open on the connection object once, the call to ExecuteReader still fails. However if I call close/open a second time, ExecuteReader succeeds. I would really like to understand what is happening here if someone has a better understanding or can explain why this voodoo works

thanks
chris
Jul 21 '05 #1
1 1218

"cp" <an*******@disc ussions.microso ft.com> wrote in message
news:BF******** *************** ***********@mic rosoft.com...
I have a business object (c#) running on an app server that talks to my sql server 2000 (2 separate physical machines). If sql server gets restarted
(i.e. someone kicks the cord out of the wall on the db server and it needs
to be restarted), the connections that IIS is maintaining seem to be
invalid.

I don't know exactly how your app is structured, but the Sever being
restarted sounds like the most likely problem. I assume you have connection
pooling turned on?

Anyway, you are using the same connection right? This doesn't happen if you
re-instantiate a new connection object and try to open it or use some other
connection somewhere else?

Also what specific exception are you getting?

If someone can verify that or explain a little about how the internals of
that works, that would be educational for me but I'll take it on faith from
the results of my tests. In order to recreate valid connections I have my
ExecuteReader statement in a try/catch. If I call close and then open on the
connection object once, the call to ExecuteReader still fails. However if I
call close/open a second time, ExecuteReader succeeds. I would really like
to understand what is happening here if someone has a better understanding
or can explain why this voodoo works.
thanks,
chris

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3018
by: PeteZ | last post by:
I'm having a problem where I exec a stored procedure (which SELECTs all rows from a table, which has 100 rows) - each row has 8 columns. When I exec the code (see below) I get 8 in oSQLDR.FieldCount (which I expect but whenever I try and reference the data in the row (oSQLDR.GetInt32(0);) I get an exception "invalid attempt to read when no data is present". If I exec the SP in an ISQL window using: EXEC getEvents, I get 100 rows...
4
9463
by: lakshmi | last post by:
Hi all, My requirement is I need to have three different recordsets open at the same time. Traversing through the 3 recordsets, I would check on the data and based on some rules, return an object from my function. Will it be efficient to use a SQLDataReader or a DataSet for this situation? I understand from the documentation that there can be only one SQLDataReader associated with a connection open at a time. So, it seems like I can't...
7
2363
by: Franck Diastein | last post by:
Hi, when I call ExportData I have this error: Invalid attempt to Read when reader is closed. Telling me that there's a problem with this line: while(_dataR.Read()){ Code: ************************************************* public void Export2CSV(){
3
5889
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the combo's text property (what the user will see). Is this possible with a SqlDataReader? Thanks
8
2083
by: bidllc | last post by:
I have a funtion that works fine and dandy when called from anywhere in my app. It will NOT work when called from inside the class in which it resides. This is the function I'm calling: "getProductByID(productID)" from inside another method in the same class. See below. This line throws a null ref exception: While dr.Read() Thanks for any insight!
8
1916
by: Jeff | last post by:
Hi - I'm having trouble Databinding a SQLDataReader to a DataGrid control. I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in a directory of my localhost on my development machine. The database is on the web. When I run the app on the local machine, IE opens, loads my aspx page from localhost, and hangs. (Eventually I get a page cannot be displayed error.)
2
2932
by: Cameron Frasnelly | last post by:
I emulated the code from the .Net Framework help (Titled "Using Stored Procedures with a Command") and I still receive and error... Error Received = "Invalid attempt to read when no data is present." BUT when I manually run the Stored Procedure and manually type in '3333' it works just fine by returning the single row for that particular work order???????? *****More Clues****
1
247
by: cp | last post by:
I have a business object (c#) running on an app server that talks to my sql server 2000 (2 separate physical machines). If sql server gets restarted (i.e. someone kicks the cord out of the wall on the db server and it needs to be restarted), the connections that IIS is maintaining seem to be invalid. If someone can verify that or explain a little about how the internals of that works, that would be educational for me but I'll take it on faith...
3
2119
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database I use System.Data.Common.DBConnection and .DBCommand. How can I keep aware from connection losses (network not availeable, db-server not available...)? Are there any strategies to detect this broken connections, and how can I
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9453
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10254
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10036
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.