Try:
CREATE PROC [dbo].Sample
@UserName varchar(100)
AS
BEGIN
SELECT Id FROM myTable WHERE UserName = @UserName
END
Then call it:
int id = -1;
using (SqlCommand com = new SqlCommand("Sample", con))
{
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@UserName", abc);
using (SqlDataReader read = com.ExecuteReader())
{
if (read.Read()) id = (int) read["Id"];
}
}