I'm retrieving immediate next record from database table using empcd(employeecode) [for which code is given below].
I wanna retrieve "next record" details from SQL SERVER 2005 with a Button Click Event but not using "EMPLOYEE ID". (SqlClient.SqlConnection)
i want to access database table nextrecord directly using either query or Logic.
Protected Sub next_rec_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles next_rec.Click
Dim cnt As String
Dim dr As SqlDataReader
cn.Open()
Dim com As New SqlCommand("select empcd from employeepersonneldetails where empcd='" & empcd.Text & "'", cn)
dr = com.ExecuteReader()
Dim ds As DataSet
If dr.HasRows Then
dr.Read()
'empcd.Text = dr("empcd").ToString
cnt = dr(0).ToString + 1
End If
cn.Close()
cn.Open()
Dim com1 As New SqlCommand("select empcd from employeepersonneldetails where empcd='" & cnt & "'", cn)
dr = com1.ExecuteReader()
If dr.HasRows Then
dr.Read()
empcd.Text = dr("empcd").ToString
''MsgBox(cnt)
End If
cn.Close()
End Sub