Click here to Skip to main content
12,955,118 members (58,509 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
on the line error come as

No data exists for the row/column. thx in advance....time is column in database

string mystring4 = drNameShow["Time"].ToString();
Posted 3-Sep-12 0:44am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

try below code
if(drNameShow["Time"] != System.DBNull.Value)
   {
      string mystring4= drNameShow["Time"].ToString();
   }
   else
   {
       string mystring4 = "NULL";
   }
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Check if the datareader has any rows before trying to access the columns in that row.
Read returns a bool indicating if there is any value available.

e.g.
if (drNameShow.Read())    
 { //processing here  }
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

hi,

try the following code. It may be help you.
if (!string.IsNullOrEmpty(drNameShow["Time"].ToString()))
{
string mystring4= drNameShow["Time"].ToString();
}
else
{
string mystring4 = string.Empty;
}


Thanks,
Viprat
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,559
CHill60 3,550
Maciej Los 3,153
ppolymorphe 2,030
Jochen Arndt 1,975


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 3 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100