Creae a stored proc. like below.
create proc sc_getCount
as
begin
select count(*) from tablename where columnname = @inputvalue
end
then call this stored procedure using either sqlcommand(if you are using layered appraoch in your application, then use them.)
eg: to call using sqlcommand see the below
SqlConnection sqlConnection1 = new SqlConnection("Your Connection String");
SqlCommand cmd = new SqlCommand();
Object returnValue;
cmd.CommandText = "StoredProcedureName";
cmd.CommandType = CommandType. StoredProcedure;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
returnValue = cmd.ExecuteScalar();
sqlConnection1.Close();
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.