Hi,I need to retrieve the Datetime from Employee details After entering Empno in a 1st text box.
Please help ASAP

This is My Coding for VB.NET
Private Sub View_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

con.Open()
cmd = New SqlCommand("regd_regdetail_Empid", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@Empid", Integer.Parse(Trim(TxtEmpid.Text)))
dr = cmd.ExecuteReader()
If dr.HasRows Then
    If dr.Read Then
        TxtEmpid.Text = dr.Item(0).ToString()
        TxtEmpame.Text = dr.GetString(1)
        TxtDOA.Text = dr.GetString(2)
        TxtDOR.Text = dr.GetString(3)
        TxtEmpno.Text = dr.Item(4).ToString()
        TxtAppointmentdate.Text = dr.GetString(5)

      End If
     End If
con.Close()

try :

TempDate = dr.Item("Appointmentdate").ToString
TxtAppointmentdate.Text = TempDate.ToString("yyyy-MM-dd")

50% working--there is no error message occur ,At the sametime Nothing Change in My module.After enter EmployementNo.And Press View.NoThing Change(No result,No error).

Assuming that the field is stored as a DateTime type,

If dr.IsDBNull(5) Then
    TxtAppointmentdate.Text = ""
Else
    TxtAppointmentdate.Text = dr.GetDateTime(5).ToShortDateString()
End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.