there are few mistakes, sample code:
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[
^]