基于给定的日期sql数据库自动更改值 [英] Automatically change value in sql database based on a given date

查看:257
本文介绍了基于给定的日期sql数据库自动更改值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在SQL自动改变价值。举一个例子一个汇入作业租来的车数据库和客户希望预约的车,let's说,七月15日(现在是4日)。当我运行我的C#程序,并在可用性列点击一个按钮保留这辆车是在RentalDate列7月15日写在数据库(未来的日期)。现在(是汽车用)它应该保持真,直到该日期( 15日)来了,然后应自动更改为False。是否有可能做这样的事情?

Is it possible to change value in sql automatically. For an example it´s a rent-a-car database and a customer wants to make a reservation for a car for, let´s say, 15th of july (now it's 4th). when i run my C# program and click on a button to reserve that car it writes in the database in the RentalDate Column July 15th(future date).Now in the Availability Column (is the car available) it should stay True until that date (15th) comes and then should be automatically changed to False. Is it possible to do something like that?

推荐答案

我会考虑不同的设计,你保持一个预约表,汽车表。然后,如果你预订车,你可以写一行到预订表的时间跨度。然后,您可以核对该表,看看汽车是可任意要求的时间跨度。

I would consider a different design where you keep a booking table and a car table. Then if you reserve a car you can write a row to the booking table with the time span. You can then check against this table to see if the car is available for an arbitrary requested time span.

这篇关于基于给定的日期sql数据库自动更改值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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