MS Access 2003:用户能够输入无效值;如何?
我有一个奇怪的现象,我无法解释也无法重现,我希望您知道用户如何输入无效值。
我有一个 Access-MDB,其表单包含一个编辑字段,该字段应该只接受没有任何日期信息的时间值。
该编辑字段的相关属性如下:
- 绑定到日期/时间数据库值(因为访问不知道仅时间数据类型)
- 格式:“时间,24 小时”
- 输入格式:“99:99”
(我使用德语版本Access 的名称,因此属性名称可能略有不同,但您会看到模式)
现在我发现用户能够在该字段中输入日期值。我几乎 100% 确定这是一次意外,并且没有以直接打开表格并编辑相应的日期/时间字段的形式进行“聪明的黑客攻击”。由于该条目是在 2009 年创建的(没有人发现这个错误),我没有机会询问用户它是如何完成的。
我发现两个错误的日期为“01.06.2000”和“01.07.2000”,我猜用户想输入时间“06:00”和“07:00”。
我尝试了我能想象到的所有输入(例如“6.0”、“6;0”、“6,0”、复制和粘贴),但我无法欺骗访问并输入除数字和冒号之外的任何内容。
您是否知道发生了什么事以及用户如何意外输入这些日期?
I have a strange phenomen I can't explain nor reproduce and I'm hoping you have an idea how it was possible for the user to enter an invalid value.
I have an Access-MDB with a form containing an edit field that should only accept time values without any date-information.
The relevant properties of that edit field are as below:
- bound to a Date/Time database value (since access know no time-only datatype)
- Format: "Time, 24hrs"
- Input Format: "99:99"
(I use the german version of Access, so the property names may be a little different, but you see the pattern)
Now I found out that a user was able to enter a date value into that field. I'm nearly 100% sure that it was an accident and no "clever hack" in the form of directly opening the table and editing the corresponding Date/Time field. Since the entry was made back in 2009 (nobody spotted the error), I have no chance to ask the user how it was done.
I found two wrong entries with the dates "01.06.2000" and "01.07.2000" and I guess the user wanted to enter the times "06:00" and "07:00".
I tried every input I can imagine (like "6.0", "6;0", "6,0", copy&paste) but I was unable to trick access and enter anything except digits and the colon.
Do you have any idea what is going on and how the user was able to enter these dates accidentially?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Jet/ACE 日期/时间值绝不会在“没有任何日期信息”的情况下存储。如果您尝试仅存储时间部分,它实际上会与第 0 天(1899 年 12 月 30 日)的相同时间一起存储。
我们只能推测 2009 年如何添加不正确的数据。如果您希望数据库引擎要求以第 0 天作为日期部分来存储日期/时间值,则可以添加表级验证规则。从表属性表中,尝试验证规则:
如果您希望 your_date_field 允许 Null,请尝试此版本:
A Jet/ACE Date/Time value is never stored "without any date information". If you attempt to store only the time component, it will actually be stored with the same time on day zero (Dec 30, 1899).
We can only speculate how the incorrect data was added back in 2009. If you want the database engine to require your Date/Time values to be stored with day zero as the date component, you can add a table-level validation rule. From the table property sheet, try this for Validation Rule:
If you want to allow Null for your_date_field, try this version:
几种可能性:
最后,如果你投入 90 个小时,是否会溢出到 4 天之类的?或许可以做到这一点。
Several possibilities:
Finally, if you put in 90 hours, does it overflow into 4 days and something? That might do it.