ich versuche, die restays in den code unten zu zeigen plus wollen auch als zähler anzeigen und speichern sie in Datenbank .. wie jeder Tag noch verbleibenden Tage erscheinen solltenIch möchte links in messagebox in unter code zeigen ... es ist kein Fehler ..aber es zeigt keine die messagebox
//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");
}
}
Und welches Problem haben Sie mit Ihrem Code? – FeliceM
Hier ist: Fehler ist: String ist nicht gültige DateTime. –
Nun, wie sieht die Saite aus? Debuggen Sie es. – LarsTech