1

The DateTimePicker1 will not be read but the other function will be read.I would like to know what is the problem in this code.

Public com As New MySql.Data.MySqlClient.MySqlCommand
Public da As New MySql.Data.MySqlClient.MySqlDataAdapter
Public dr As MySql.Data.MySqlClient.MySqlDataReader
Public dt As New DataTable
Public ds As DataSet

Private Sub frmupdateaccount_Load(sender As Object, e As EventArgs) Handles MyBase.Load


    Dim READER As MySql.Data.MySqlClient.MySqlDataReader
    Dim query As String

    con.Open()

    query = "Select * from user_tbl where userid='" & txtuserid.Text & "'"
    com = New MySql.Data.MySqlClient.MySqlCommand(query, con)

    READER = com.ExecuteReader

    While READER.Read

        txtcontactnumber.Text = READER.GetString("contactnumber")
        cbxgender.Text = READER.GetString("gender")
        datetimepicker1.Text = READER.GetString("dateofbirth")

    End While

    con.Close()
End Sub
Steve
  • 213,761
  • 22
  • 232
  • 286
  • This happens when you think that a date is a string. This is not true. What is the value of the field "dateofbirth" in the database? What is its datatype? What is your locale settings "dd/MM/yyyy" or something else? I repeat, dates are not strings and when you treat them as strings strange things happens when automatic conversion kicks in – Steve Aug 13 '16 at 09:36
  • By the way, if one of you users is malicious enough to [try this](http://stackoverflow.com/questions/332365/how-does-the-sql-injection-from-the-bobby-tables-xkcd-comic-work) you are in deep troubles – Steve Aug 13 '16 at 09:38
  • datetimepicker1.Text = READER.GetDateTime("dateofbirth") - Thanks Steve~ – Karl Angelo Solis Gamayo Aug 13 '16 at 12:26

0 Answers0