0

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()

Edited by pearl.kumar1: Test

3
Contributors
4
Replies
20
Views
4 Years
Discussion Span
Last Post by TnTinMN
0

try :

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

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).

0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.