ASP .NET下拉列表框中的"SQL时间"字段 [英] SQL Time field from ASP .NET dropdownlist boxes

查看:157
本文介绍了ASP .NET下拉列表框中的"SQL时间"字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有一个时间字段,需要从两个列表框中输入:小时:分钟.一个列表框代表小时,其他列表代表分钟.我需要合并到两个列表框selecteditems以形成有效的时间字段.

I have a time field in a database, and need to input: hours : minutes, from two listboxes. One listbox represents the hours, the other the minutes. I need to merge to two listbox selecteditems to form a valid time-field. 

我已经尝试过:

lstHours.SelectedItem.Value& :"& lstMinutes.SelectedItem.Value

和其他类似内容,但似乎没有任何作用.

And others similar, but nothing seems to work. 

任何有建议吗?

更新:

我已经意识到这不是时间类型,而是引起问题的日期类型.从如下所示的日历中选择日期:

I''ve realised it''s not a time type that''s the date type that is causing the issues. The date is selected from a Calendar like so:

dbSQL_Location_Save ="INSERT INTO tblCalendar_Location(locUser, locDate ,locTime,locLocation,locDescription)VALUES("& PublicFunctions. ConvertString(lstLocation_Staff.SelectedItem.Value)&'',``& calLocation_Calendar.SelectedDate &"'',"& dtLocation_Time.ToString("hh:mm:ss )&","& PublicFunctions.ConvertString(txtLocation_Location.Text)&'',"& PublicFunctions.ConvertString(txtLocation_Description.Text)&")"

dbSQL_Location_Save = "INSERT INTO tblCalendar_Location (locUser, locDate, locTime, locLocation, locDescription) VALUES (''" & PublicFunctions.ConvertString(lstLocation_Staff.SelectedItem.Value) & "'', ''" & calLocation_Calendar.SelectedDate & "'', ''" & dtLocation_Time.ToString("hh:mm:ss") & "'', ''" & PublicFunctions.ConvertString(txtLocation_Location.Text) & "'', ''" & PublicFunctions.ConvertString(txtLocation_Description.Text) & "'')"

建议?

推荐答案

您要构建的是字符串.您如何将其传递给数据库?您是否在使用参数化查询?如果您将时间存储在数据时间中并传递给时间该怎么办?

What you''re building is a string.  How are you passing it to the database ? Are you using a parameterised query ? What if you stored the time in a datatime and passed that in ?


这篇关于ASP .NET下拉列表框中的"SQL时间"字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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