如何验证msaccess数据库中存在的特定日期 [英] how to validate the particular date exists in the msaccess database

查看:115
本文介绍了如何验证msaccess数据库中存在的特定日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

订购日期课程名称



2/25/2013 GMDSS

2/26/2013 ASM



设计如下



订购日期textbox1(日历)

CourseName textbox2



当我在日历中选择日期时,日期显示在文本框1中。

in courseName进入课程并保存在数据库中。

$ b



i想验证,如果用户选择相同日期并保存在数据库中

那个时间显示消息选择日期已经存在。





如何验证所选日期是否存在于数据库中。



之前保存在数据库中显示弹出消息所选日期已经存在。



注意它是windows应用程序。



我该怎么办?



请帮助我。

解决方案

你好朋友,



你可以用这种方式...



保存记录之前你的数据库,你需要激活选择查询到你的数据库有条件和传递所选数据作为条件参数where,如果选择任何记录它意味着你的数据库中也有一个具有相同日期的记录,那么你可以弹出一个消息,数据库中已存在日期并跳过插入数据的过程。





或者这样......





您可以在日期列中指定唯一约束,因此每次要插入数据时,如果已经存在相同的数据,那么它将会存在抛出唯一约束违反错误,这意味着您需要显示您的消息,数据库中已存在所选日期。


Order Date CourseName

2/25/2013 GMDSS
2/26/2013 ASM

Design as follows

Order Date textbox1 (calendar)
CourseName textbox2

When i select the date in the calendar that date is display in the textbox1.
in courseName enters the course and save in the database.



i want to validate, if the user select the same date and save in the database
that time shows the message selected date is already exists.


how to validate the selected date is exists in the database.

for that before saving in the database shows the popup message the selected date is already exist.

Note it is windows application.

How can i do?

Please help me.

解决方案

Hello friend,

you can go with this way...

before saving record to your database, you need to fire select query to you database with having where condition and pass selected data as where condition parameter, if any record is selected it means there is also a record having same date in your database, so then you can popup a message that date is already exist in database and skip process of inserting data.


Or this way....


You can specify unique constrain on your date column, so every time while you are going to insert data and if already same data is exists then it will throw unique constraint violated error, that means you need to show your message that selected date is already exist in database.


这篇关于如何验证msaccess数据库中存在的特定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆