Connecting Tech Pros Worldwide Help | Site Map

Saving times in database with different dattime pickers

Member
 
Join Date: Oct 2006
Location: Netherlands
Posts: 92
#1: Sep 17 '09
Hello!

I am creating a program where i can fill in a list of open/close times.
In total i have 14 datetimepickers which i set to custom format with hours and minutes.
Every dtpicker has an name (eg mondayopen, mondayclosed, tuesdayopen, tuesdayclosed and so on).

After setting the times right i want to throw everything at once into the datatabse.
Is there some kind of manner to loop through the datetimepickers and insert them into the db or do i have to do them all seperately?

Thanks!
Paul
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#2: Sep 17 '09

re: Saving times in database with different dattime pickers


You could create Pairs of DateTimePickers and add these Pairs to a List Of Pairs.

Loop through the list of pairs to retrieve their values (open, close times)

Add these values to your parameters involved in your your database update....

Or you could add all of the DateTimePickers to a List Of DateTimePickers and then, as you loop through them, use Reflection to easily add the values to the parameters involved in your database update...just make sure to name the DateTimePickers appropriately.

There's quite a few ways to do this.
Member
 
Join Date: Oct 2006
Location: Netherlands
Posts: 92
#3: Sep 18 '09

re: Saving times in database with different dattime pickers


Hi Thanks,
I was thinking of the last one, making an array of datetimepickers and do the rest from there.
Thanks! i will try that!

Cheers,
Paul
Reply