Results 1 to 5 of 5

Thread: [2005] DateTime Bindings DateTimePickers

Threaded View

  1. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] DateTime Bindings DateTimePickers

    First up, if you're manually moving the data from the controls to the DataTable then there's no binding going on. The whole point of binding is so you do NOT have to write your own code to move the data.

    As for the code you do have, don't ever use strings to manipulate dates if it can be avoided. Your DataTimePickers already contain DateTime values and you want a DateTime value so there is no reason at all for using strings anywhere in the equation.

    Also, please use descriptive names for all variables. "DateTimePicker15" and "DateTimePicker16" mean nothing to anyone.
    vb.net Code:
    1. Me.DsTradeShow1.Tables("Tradeshow_Details").Rows(0).Item("Show_Date") = Me.datePicker.Value.Date.Add(Me.timePicker.Value.TimeOfDay)
    That code gets the DateTime from the date picker, zeroes the time and then adds the TimeSpan from the time picker.
    Last edited by jmcilhinney; Jan 26th, 2009 at 07:52 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width