im пытается показать оставшиеся дни в коде ниже, а также хочу показать как дни счета и сохранить его в База данных .. как каждый день оставшиеся дни должны, как представляется, изменитьЯ хочу показать левые дни в окне сообщений в нижнем коде ... нет ошибки .. но ее нет показ в ящике сообщений
//i want to get the two dates which is already saved in sql and then
//calculating the remaining days
//reading the data
using (SqlDataReader read = cmd.ExecuteReader()) {
//loop throught the reader
while (read.Read()) {
// putting the salarydate value from database to first variable
String first =(read["salarydate"].ToString());
// putting the expirydate value from database to second variable
String Second = (read["expiredate"].ToString());
//converting the first fron string to datetime and then saving it to another
//datetime variable name salaryDate
DateTime salaryDate = DateTime.ParseExact(first, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
//converting the second fron string to datetime and then saving it to another
//datetime variable name expireDate
DateTime expireDate = DateTime.ParseExact(Second, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
//timepaning between two
TimeSpan t1 = expireDate - salaryDate;
//storing the days from t1 to daysleft which means days remaining
int daysleft = t1.Days; //days left
//this message box is not showing
//i also want to save the difference in sql and when that difference become
//zero , i want to put condition on that ..
MessageBox.Show(daysleft.ToString(),"Days Left");
}
}
И в чем проблема с вашим кодом? – FeliceM
Сверху: Ошибка: Строка не действительна DateTime. –
Ну, как выглядит строка? Отлаживайте его. – LarsTech