本文介绍了如何以新的形式显示原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 当我的计算机日期为(日期-before_day)时,如何以新的形式显示原因,当我的计算机日期>时,它将停止显示日期。这是mysql表 text> reminder_id date cause before_day 1 2016-06-05 sevicing 2 2 2016-06-05 mobil change 1 3 2016-06-14 body color 2 4 2016-06-25烟雾测试0 5 2016-06-26齿轮换油1 ---------- void show_reminder() { string date = 串 .Empty; string cause = string .Empty; string before_day = string .Empty; string sToday = DateTime.Now.ToString( YYYY-MM-DD); string t = DateTime.Now.ToString( DD / MM / YYYY); string myConnection = datasource = localhost; port = 3306; username = root; password = root; MySqlConnection myConn = new MySqlConnection(myConnection); MySqlCommand SelectCommand = new MySqlCommand( SELECT * FROM bs.reminder + WHERE From_Days (To_Days(date) - before_day)=' + sToday + '; ,myConn); MySqlDataReader myReader; myConn.Open(); myReader = SelectCommand.ExecuteReader(); while (myReader.Read()) { date = DateTime.Parse(myReader.GetString( 1 ))。ToString( dd / MM / yyyy ); km = myReader.GetString( 3 ); before_day = myReader.GetString( 4 ); cause = myReader.GetString( 2 ); string text1 = cause; string text2 = date; string text3 = before_day; Form2 f2 = new Form2(text1,text2,text3,t); f2.ShowDialog(); } } 代码块添加 - OriginalGriff [/ edit] 解决方案 how to display the cause in a new form when my "computer date" will be (date -before_day) and it will stop displaying when my "computer date" > date. ? this is mysql tablereminder_id date cause before_day1 2016-06-05 sevicing 22 2016-06-05 mobil change 13 2016-06-14 body colour 24 2016-06-25 smoke test 05 2016-06-26 gear oil change 1---------- void show_reminder() { string date = string.Empty; string cause = string.Empty; string before_day = string.Empty; string sToday = DateTime.Now.ToString("yyyy-MM-dd"); string t = DateTime.Now.ToString("dd/MM/yyyy"); string myConnection = "datasource= localhost;port=3306;username=root; password=root"; MySqlConnection myConn = new MySqlConnection(myConnection); MySqlCommand SelectCommand = new MySqlCommand("SELECT* FROM bs.reminder " + " WHERE From_Days( To_Days(date) - before_day ) ='" + sToday + "' ;", myConn); MySqlDataReader myReader; myConn.Open(); myReader = SelectCommand.ExecuteReader(); while (myReader.Read()) { date = DateTime.Parse(myReader.GetString(1)).ToString("dd/MM/yyyy"); km = myReader.GetString(3); before_day = myReader.GetString(4); cause = myReader.GetString(2); string text1 = cause; string text2 = date; string text3 = before_day; Form2 f2 = new Form2(text1, text2, text3, t); f2.ShowDialog(); } }[edit]Code block added - OriginalGriff[/edit] 解决方案 这篇关于如何以新的形式显示原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-30 22:28