2010-08-05 49 views
0

使用C#& Mysql的大於或等於日期都不應該允許進入

當我在文本框中輸入的日期應與日期表進行比較,如果它等於它應該拋出錯誤信息,它應該只允許除日期

就越大實例

Table1 

ID Date 

001 2010-08-05 
002 2010-08-02 
.... 

When i enter the date in the textbox like - 2010-08-04, it should compare with Date in the table1, if it is equal or less than max(date) from table1 then it should throw a error message, otherwise it should allow to insert a date. 

是新到mysql & C#中,如何在C#& Mysql的做到這一點。

需要一些代碼的幫助。

回答

1

我會先運行一個查詢並獲取最大日期到我的前端應用...然後根據應用是否是網頁應用程序或Windows應用程序,我會比較驗證(ASP.NET)使用這個值或Textbox_Validating事件來比較值...

如果您不熟悉如何使用比較驗證器或驗證事件,請告訴我,我可以在此發佈一些鏈接。

如果你想要把這個限制在你的表本身,你可能需要使用約束/觸發器...我不知道MySQL的很多工作來幫助你在這裏。

相關問題