Get output from Stored Procedure using Console
<p>Hi I'm trying to produce an output from console but keep getting the error message </p>

<blockquote>
  <p>Procedure or function 'p_Date_sel'
  expects parameter '@DateID', which was
  not supplied</p>
</blockquote>

<p>Suppose to get the DateID and display all the data,please tell me what I'm doing wrong.</p>

<p>Below is my stored procedure</p>

<pre><code>ALTER procedure [dbo].[p_Date_sel]
@DateID int

AS
BEGIN
SELECT DateTypeID , Date , Name, Notes
FROM dbo.Dates
WHERE DateID= @DateID
END

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;


namespace ExecuteStoredProcedure
{
    class Program
    {
        private int _dateID;
        private int _dateTypeID;
        private DateTime _date;
        private string _name;
        private string _notes;

        public Program() 
        {
            _dateID = 0;
        }

        public Program(int dateID) {
            _dateID = dateID;
        }
        public Program(int datetypeID,DateTime date,string name,string notes){

            _dateTypeID = datetypeID;
            _date = date;
            _name = name;
            _notes = notes;
        }

       public int dateID 
       { 
           get {return _dateID;} 
       }
       public int dateTypeID 
       {
           get { return _dateTypeID; }
           set { _dateTypeID  = value; } 
       }
       public DateTime date 
       {
           get {return _date ;}
           set { _date = value;} 
       }
       public string name 
       {
           get { return _name;}
           set { _name = value; } 
       }
       public string notes 
       {
           get { return _notes;}
           set { _notes = value; }
       }

        public void LoadData()
        {
            SqlConnection conn = new SqlConnection("Data Source=mycbj01psql03\\sandbox01;Initial Catalog=DBRMS;Integrated Security=True");
            conn.Open();
            SqlCommand command = new SqlCommand("p_Date_sel", conn);
            command.CommandType = CommandType.StoredProcedure;
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read()) 
            {
                _dateTypeID = Convert.ToInt16(reader["DateTypeID"]);
                _date = Convert.ToDateTime(reader["Date"]);
                _name = reader["Name"].ToString();
                _notes = reader["Notes"].ToString();
            }


            reader.Close();
            conn.Close();

           }
    }
}
</code></pre>

<p>My Main Program</p>

<pre><code>    namespace ExecuteStoredProcedure
    {
    class TestClass 
    {
        public static void Main(string[] args)
        {

            Program p = new Program(5);
            p.LoadData();

            Console.WriteLine("DateID = " + "" + p.dateID);
            Console.WriteLine("DateTypeID = " + "" + p.dateTypeID);
            Console.WriteLine("Date = " + "" + p.date);
            Console.WriteLine("Name = " + "" + p.name);
            Console.WriteLine("Notes = " + "" + p.notes);

            Console.ReadLine();
        }
    }
}
</code></pre>
