I am trying to insert a row in ms-sql table using the following code
SqlCMDText = "INSERT INTO attendance(date, time_in, time_out, time_total, status,";
SqlCMDText += " is_late_in, is_half_day, is_early_out, user_id, remarks)";
SqlCMDText += " VALUES('@yestarday_date', 'NA', 'NA', 'NA', 'ABSENT', 'NA', 'NA', 'NA', 52, 'DONE BY PORTAL')";
SqlCMD = new SqlCommand(SqlCMDText, SqlCON);
SqlCMD.Parameters.AddWithValue("@yestarday_date", Yestarday);
SqlCMD.ExecuteNonQuery();
Where Yestarday is a string variable containing short date format like "04/04/2011". I also tried passing datetime variable itself but it does not work, I get same error as below.
"Syntax Error Converting DateTime From Character String"
What format should I use to make it work?
Thanks.