且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用数据读取器读取日期选择器

更新时间:2023-09-02 11:03:40

所以这不能正常工作吗?
So this isn''t working correctly?
if (appointReader["AppointmentDate"] == dateTimePickerAppoint)



如果是这样,几乎没有什么要检查的
-appointReader["AppointmentDate"]的值是没有时间的日期,如果不是,则将时间信息存储在数据库中
-将Value 属性用于dateTimePickerAppoint
-dateTimePickerAppoint.Value是否具有时间信息(如果有),如果只想处理日期,请将其删除

另外,您不需要数据库中的时间信息,请考虑将数据类型从datetime 更改为date

附带说明一下,如果connect 是数据库连接,我认为您应该在显示消息框之前将其关闭,以便尽快释放资源.



If so, few things to check
- is the value of appointReader["AppointmentDate"] a date without time, if not you''re storing time information in the database
- use Value property for dateTimePickerAppoint
- does the dateTimePickerAppoint.Value have time information, if it does, remove it if you want to handle only dates

Also you don''t need time information in the database, consider changing the data type from datetime to date

As a side note, if the connect is the database connection, I think you should close it before you show the message box in order to release the resources as soon as possible.