如何从下拉列表中获取数据以在sql中保存hh:mm [英] how to fetch data from drop down list to save hh:mm in sql
问题描述
我创建了下拉列表,该列表从早上8点到晚上9点填充了30分钟。它是这样的,比如上午8:00,上午8:30,上午9:00,上午9:30,......,下午12:30等。当用户从下拉菜单中选择任何一个hh:mm列表并将其保存在MS Sql中,如hh:mm。我创建了一个表,它有一个名为SendTime的列。数据类型设置为Time(7)。这是正确的方法吗?现在,我的问题是如何在c#代码中将这些数据定义为小时和分钟,以便我可以将它们保存在sql中。任何帮助表示赞赏。
同样的事情也适用于日历。我有一个日历。我知道如何只获得日期格式(dd / mm / yyyy),但我不知道如何只在MS sql中保存日期(dd / mm / yyyy)。
请帮忙。感谢
I have created drop down list that has populated 30 minutes interval from 8:00 am 9:00 pm. It is something like this 8:00am, 8:30 am, 9:00 am, 9:30 am, ......, 12:30 pm, etc. When user select any of this hh:mm from drop down list and save it in MS Sql as hh:mm. I created a table and it has a column called SendTime. Datatype is set up as Time(7). Is it correct way to do. Now, my question is how to define this data as hours and minutes in c# code so that I can save them in sql. Any help is appreciated.
Same thing also applies to Calendar. I have a calendar. I know how to get only date format (dd/mm/yyyy), but I do not know how to get only date (dd/mm/yyyy) is saved in MS sql.
Please help. Thank
推荐答案
在SQL中将数据类型设为nvarchar n保存。
在C#中将其视为字符串只有bcoz,在下拉菜单上选择你将获得时间为上午8:30,
其中包括数字,双冒号和'am'也。
更好的方法是将它保存为c#中的sql n字符串中的nvarchar。
i对Hijri日期使用相同的。希望你知道hirji日期。
祝你好运。
In SQL take the datatype as nvarchar n save it.
In C# take it as string only bcoz, on dropdown select u will get the time as 8:30am,
which includes numeric,double colon & 'am' also.
its better way to save it as nvarchar in sql n string in c#.
i use the same for Hijri dates. Hope u know the hirji date.
Best of luck.
这篇关于如何从下拉列表中获取数据以在sql中保存hh:mm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!