[英]Comparing three values from client side with the other three values in the database
I am still new in asp programming and i am having difficulty in figuring how to compare the values from client side with the database. 我仍然是ASP编程的新手,我很难确定如何比较客户端和数据库中的值。
For example, i am going to insert date
, starttime
and room
values into the database but under one condition which they cannot be the same with the date
, starttime
and room
values that has already exist in the database. 例如,我打算将date
, starttime
和room
值插入数据库,但是在一种情况下,它们不能与数据库中已经存在的date
, starttime
和room
值相同。
Much thanks ! 非常感谢 !
First of all see whether the similar entry already exist in table or not. 首先,查看表中是否已存在类似条目。 If similar entry is not exist in table only then you may provide entry into databse. 如果仅在表中不存在类似条目,则可以将其提供到数据库中。
Make similar query as below: 进行类似的查询,如下所示:
SELECT * FROM yourTable WHERE date = yourDate AND starttime = yourStarttime AND room == yourRoom
If returned result from above query is NULL
then make entry into database , otherwise skip entry operation. 如果上述查询返回的结果为NULL
则进入数据库,否则跳过输入操作。
if exists(select * from tablename where date = date and starttime = starttime and date=date)
begin
--- insert (here It Check data is There If there in begin statement U can insert
end
else
begin
--if any operation if No data there
end
or 要么
if exists(select * from tablename where date = date and starttime =
starttime and date=date)
begin
declare @count int ;
set count= select count(*) from tablename where date = date and starttime=starttime and date=date
if(@count ==0 )
begin
-- Count is Zero
--- insert (here It Check data is There If there in begin statement U can
end
else
begin
-- Count more than Zero
end
end
else
begin
--if any operation if No data there
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.