Click here to Skip to main content
15,888,053 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

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. 

I've tried:

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

And others similar, but nothing seems to work. 

Any suggestions?

UPDATE:

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) & "')"

Suggestions? 

Posted
Updated 24-Nov-09 1:59am
v2

1 solution

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 ?

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900