Guest User

Untitled

a guest
Aug 24th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. Generate 'Previous' and 'Next' button with dataset
  2. Private Sub Command_Previous_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command_Previous.Click
  3. Cnn = New MySqlConnection
  4. Cnn.ConnectionString = "server=127.0.0.1;user=root;password=xxx;database=database;port=3306;"
  5. Cnn.Open()
  6. Dim DA As New MySqlDataAdapter("SELECT * FROM Staff WHERE full_name < '" & lbl_Name.Text & "' ORDER BY full_name, login_id DESC", Cnn)
  7. Dim DS As New DataSet
  8. Dim DR As DataRow
  9. Dim CurrentRow As Integer
  10.  
  11. DA.Fill(DS, "Staff")
  12. If DS.Tables(0).Rows.Count = 0 Then
  13. MessageBox.Show("Beginning of Record List", "User", MessageBoxButtons.OK, MessageBoxIcon.Information)
  14. Else
  15. CurrentRow = Math.Min(DS.Tables(0).Rows.Count - 1, CurrentRow + 1)
  16. DR = DS.Tables(0).Rows(CurrentRow)
  17.  
  18. txt_Name.Text = DR("full_name")
  19. txt_Login.Text = DR("login_id")
  20. txt_Password.Text = DR("passwd")
  21.  
  22. If DR("user_level").ToString = "Normal User" Then
  23. rad_Normal.Checked = True
  24. Else
  25. rad_Admin.Checked = True
  26. End If
  27. End If
  28.  
  29. Cnn.Close()
  30. Cnn = Nothing
  31. End Sub
  32.  
  33. CurrentRow = Math.Max(0, CurrentRow - 1)
  34. DR = DS.Tables(0).Rows(CurrentRow)
Add Comment
Please, Sign In to add comment