15,903,856 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by furynight8 (Top 4 by date)
furynight8
16-Oct-14 5:13am
View
I have tried to solve my problem by below approach.
bool endOfFile = !actionRtfReader.HasRows;
while (!endOfFile)
{
try
{
bool readResult = actionRtfReader.Read();
endOfFile = !readResult;
}
catch (Exception rowLevelException)
{
if (ex.Message.ToString().ToLower().Contains("connect"))
{
Environment.Exit(0);
}
else
{
MessageBox.Show(rowLevelException.GetType().ToString() + " : " + rowLevelException.Message);
}
}
}
I am checking whether the exception message contains "connect". If it contains "connect" , i am terminating my program.
Kindly advise me whether my approach is correct.
furynight8
16-Oct-14 5:11am
View
Deleted
I have tried to solve my problem by below approach.
furynight8
16-Oct-14 4:11am
View
Hi,
I am checking the connection while saving the details in DataReader. I have millions of records to be fetched from database. Since DataReader is a connected object, I am getting exception in each objDataReader.Read() statement. For example, say i have fetched around 5000 rows from database using the Read() statement and the connection to database is lost while fetching 5001 row.
There may be many exceptions while objDatareader.Read(), but only when the exception occurs due to connection lost, i have to terminate my program.
Kindly advice me how to proceed in this.
furynight8
16-Oct-14 3:53am
View
Hi All,
First of all, thanks a lot for all your replies.
I am having the below code in my application, to catch row level exceptions.
OracleCommand actionRtfCommand = new OracleCommand("select * from ACTION_RTF", conn);
actionRtfCommand.InitialLONGFetchSize = -1;
OracleDataReader actionRtfReader = actionRtfCommand.ExecuteReader();
// read only one record each roundtrip to avoid that exception has consequences for subsequent read statements
// (when the exception occurs the buffer becomes corrupted giving problems for subsequent read operations to the same buffer)
// Since this reduction of fetchsize (increasing number of roundtrips) has a significant performance penalty (typical fetchsize is 131072)
// it should only be applied when command involves LONG or LONG RAW columns
actionRtfReader.FetchSize = actionRtfReader.RowSize;
bool endOfFile = !actionRtfReader.HasRows;
while (!endOfFile)
{
try
{
bool readResult = actionRtfReader.Read();
endOfFile = !readResult;
}
catch (Exception rowLevelException)
{
// handle exception
MessageBox.Show(rowLevelException.GetType().ToString() + " : " + rowLevelException.Message);
}
}
DataReader will fetch only one row at a time and if any exceptions occurs while reading it will be caught in the exception.
Sometimes while executing the loop, the connection to the database is lost due to some reason. So only in condition when the connection to the database is lost, i have to terminate the program. In other conditions, it should work as it is working now.