Hi All,
Thank you for helping.
Now i'm getting an error on dates,is this the correct way for me to do this,Planning on getting all the parameters out just from the dateID
class Program
{
private int _dateID;
private int _dateTypeID;
private DateTime _date;
private string _name;
private string _notes;
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; set; }
public int dateTypeID { get; set; }
public DateTime date { get; set; }
public string name { get; set; }
public string notes { get; set; }
public void LoadData(int p)
{
SqlConnection conn = new SqlConnection("Data Source=mycbj01psql03\\sandbox01;Initial Catalog=DBRMS;Integrated Security=True");
SqlCommand command = new SqlCommand("p_Date_sel", conn);
SqlParameter parameter = new SqlParameter();
parameter.ParameterName = "@DateID";
parameter.Value = p;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "p_Date_sel";
command.Parameters.Add(parameter);
conn.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader["Dates"]);
}
conn.Close();
}
}
public static void Main(string[] args)
{
Program p = new Program(56);
p.LoadData(56);
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();
}