I want to select single value from Table and display in lable.
I wrote a program :-
protected static string ConStr = "Data Source=URJIT6;Initial Catalog=Employee;Integrated Security=True";
protected SqlConnection NewCon = new SqlConnection(ConStr);
String QStr = "SELECT Username FROM Register WHERE LoginID=' " + LoginIdtxt.Text.ToString() + "'";
SqlCommand SqlCmd2 = new SqlCommand(QStr, NewCon);
NewCon.Open();
SqlDataReader Reader;
Reader = SqlCmd2.ExecuteReader();
Reader.Read();
l1.Text =Reader("Username");
But This is not working.
and Display error:
Error 1 'Reader' is a 'variable' but is used like a 'method'
It can be solve? Any other solution is possible?