Get int value from command in c#

Viewed 20934
string sql = "Select UserId From User where UserName='Gheorghe'";


SqlCommand cmd=new SqlCommand(sql, connection);
cmd.ExecuteScalar(); //this statement return 0

but I want to get the id of user? how can I get it?

3 Answers
Related