conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
poll = new Poll();
poll.Id = (int)cmd.Parameters[“@ID”].Value;
poll.Question = (string)cmd.Parameters[“@Question”].Value;
poll.DatePosted = (DateTime)cmd.Parameters[“@date”].Value;
while (reader.Read())
{
}
reader.Close();
}
else
{
reader.Close();
}
Stored Procedure For that
DECLARE @ID INT
DECLARE @Question VARCHAR(128)
DECLARE @Date DATETIME
EXEC db_Polls_GetCurrentPoll
@ID OUTPUT,
@Question OUTPUT,
@Date OUTPUT
SELECT @ID AS ' ID'
SELECT @Question AS
SELECT @DateAS 'Date Posted'