locked
Populating a date time picker when a user enters an ID number into a textbox RRS feed

  • Question

  • I am using a vb windows application

    I need to allow a user to enter their ID num in a text box and it need to automatically populate their date of birth please help.

    Wednesday, January 25, 2012 9:58 AM

Answers

  • Isi,

    Important is how you get the Data from the user.

    SqlReader, DataContext, Dataset/DataTable, Entitiy.

    But somewhere in some of those hidden is an Update command. 

    You should add to that the DateTimeValue from the DateTimePicker using a parameter (or an method which does that for you depending how you got the data)

    In the most basic way this would be

     

    YourCommand.Parameters.AddWithValue("@TheParameterWhichIsUsed", DateTimePicker.Value) 
    

     

    be aware the value of the datetimepicker as many make the mistake to use the text.

    Then you can do the update but that is depending from the way you got the data.


    Success
    Cor

    • Edited by Cor Ligthert Friday, January 27, 2012 9:11 AM
    • Proposed as answer by Mark Liu-lxf Thursday, February 2, 2012 7:39 AM
    • Marked as answer by Mark Liu-lxf Friday, February 10, 2012 3:05 AM
    Friday, January 27, 2012 9:10 AM

All replies

  • I am using a vb windows application

    I need to allow a user to enter their ID num in a text box and it need to automatically populate their date of birth please help.

    Populate where? 

    Be aware that a windows application is Windows Presentation Foundation, and probably you are using Windows Forms.

     


    Success
    Cor
    Wednesday, January 25, 2012 10:39 AM
  • Hi isiR19,

    Welcome to the MSDN forum.

    I assume you using Windows Forms (if not, please let me know). I think more information is needed before solve your issue. How to get the birth of the people form the ID number? Does all the information stored in the database? Witch type of the birth stored in it?
    Here is a simple sample, hope it helps:

    Dim Birth As Date = New DateTime(2012, 1, 27)
            DateTimePicker1.Value = Birth
    
    
    I look forward to your reply.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us
    Friday, January 27, 2012 7:56 AM
  • Yes all the information is stored in an MSSql database

    i have a textbox in which the user needs to enter their ID Num eg 900810etc

    which their birth date would be 10/08/1990

    and below the ID num i have a date time picker which allows the user to select their birth date


    Regards Ismail
    • Edited by isiR19 Friday, January 27, 2012 8:25 AM
    Friday, January 27, 2012 8:21 AM
  • Hi isiR19,

    So you just need to change my code a little to fit your issue:

     

         Dim dateString As String = "10/08/1990"
            Dim date1 As Date = Date.Parse(dateString, _
                                     System.Globalization.CultureInfo.InvariantCulture)
            DateTimePicker1.Value = date1
    

     

    It works well for me, hope it helps.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us


    Friday, January 27, 2012 8:36 AM
  • Hi 

     

    I suggest you to look up the birthdate in the event textchanged of your textbox according to the ID num(so it will be a select birthdate from urtable where id='" & Textbox1.text &"' and to affect the value to the datatimepicker .

    And you convert the value from database to a date to match the type of the value of datatimepicker

     

    Regards


    Best Regards...Please mark as answer if my post is helpful
    Friday, January 27, 2012 9:02 AM
  • Isi,

    Important is how you get the Data from the user.

    SqlReader, DataContext, Dataset/DataTable, Entitiy.

    But somewhere in some of those hidden is an Update command. 

    You should add to that the DateTimeValue from the DateTimePicker using a parameter (or an method which does that for you depending how you got the data)

    In the most basic way this would be

     

    YourCommand.Parameters.AddWithValue("@TheParameterWhichIsUsed", DateTimePicker.Value) 
    

     

    be aware the value of the datetimepicker as many make the mistake to use the text.

    Then you can do the update but that is depending from the way you got the data.


    Success
    Cor

    • Edited by Cor Ligthert Friday, January 27, 2012 9:11 AM
    • Proposed as answer by Mark Liu-lxf Thursday, February 2, 2012 7:39 AM
    • Marked as answer by Mark Liu-lxf Friday, February 10, 2012 3:05 AM
    Friday, January 27, 2012 9:10 AM