Harish Batchu

Harish Batchu

  • NA
  • 255
  • 65.6k

I am getting an error when reading data from sqldatareader

Oct 10 2018 9:55 PM
 
Hii
 I am attaching the command
 
SqlCommand cmd = new SqlCommand("select SUM(cast(UserIncomeDetail_Amount as int)) as amount from ft_UserIncomeDetail where User_Uniq='Harish'", con);
con.Open();
sda=cmd.ExecuteReader();
if (sda != null)
{
ViewBag.income = sda["amount"];
}
 
 
error-
System.InvalidOperationException: 'Invalid attempt to read when no data is present.'
please the fix issue
 

Answers (3)