Click here to Skip to main content
15,886,038 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
SqlDataReader reader = com.ExecuteReader;
       if (reader.HasRows == true)
       {
           while (reader.Read)
           {

               Username = reader("Username").ToString;
               UserId = reader("UserId").ToString;
               //Get_OneItem = true;
               return true;

               //Std_img = reader("Std_img").ToString
           }
       }
Posted

1 solution

there are few mistakes, sample code:
C#
SqlDataReader reader = com.ExecuteReader();
if (reader.HasRows)
{
   while (reader.Read())
   {
 
      Username = reader["Username"] as string;
      UserId = reader["UserId"]  as string;
      return true;
   }
}


if you want one item, then replace your while loop with if
also check the msdn documentation which available with both c# and vb.net code samples
Retrieving Data Using a DataReader[^]

online code converters may help you:
developerfusion[^]
telerik converter[^]
 
Share this answer
 
v3

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900