I am interrupted in my code. Whilst using OLEdbReader object.
I would like to skip the last row of reader object ,which contains non-acceptable string .At time of reading object it shows "HasRows" true..while read by read operation gives me null.
i,ve tried string.IsnullorEmpty().no success.
Help is really appreciated.
Regards
Sachin Kalia

Sachin KaliaPosted Jul 17, 2012, 6:13 AM
This is the problem with the OleDbDataReader is that you don't know how many rows there are to be read until it's read the last one.
Whislt i've found a workaround for this and would like to share with you all .
@ time of reading CSV used this code,yes it may be bit odd but satiesfied my requirement
VulpesPosted Jul 17, 2012, 5:53 AM
So, unless you know in advance how many records are going to be returned, there's no way to skip reading the last row entirely.
Jignesh TrivediPosted Jul 16, 2012, 11:59 PM
You may use the "as" operator combined with the "??" operator for default values. Value types will need to be read as nullable and given a default.
string test1 = sqlreader[index] as string; // for string value.
int myInt = sqlreader[index] as int? ?? default(int); // for int value.
hope this will help you.
Sachin KaliaPosted Jul 16, 2012, 11:56 PM
Thanks for your initiate.
I've already tried this.this function use to check the Column value existence.
I want to skip the complete row from any excel sheet or csv file.
Kind of we do have skip function in LINQ.
I'm using C# 3.0.
Thanks
Chees DotNet :)
VulpesPosted Jul 16, 2012, 9:44 AM
For example, if it's the column with an index of 'n' that you're trying to read:
if (!reader.IsDBNull(n))
{
// read the actual value
}
Sachin KaliaPosted Jul 16, 2012, 9:20 AM
There is no update on this article since few days.
Can anyone have a look and advise me to come out from this issue.
Hihgly Thankful.