Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. Imports System.Data.SqlClient
  2. Module Module1
  3.  
  4. Public query As String
  5. Public con As SqlConnection
  6. Public ds As DataSet
  7. Public da As SqlDataAdapter
  8. Public cmd As SqlCommand
  9. Public dr As SqlDataReader
  10.  
  11. Function koneksi() As Boolean
  12. Dim constring As String
  13. constring = "Data source = 192.168.88.4;initial catalog=AAJIHRD;user=hrd_usr;password=zxcv4321"
  14. 'constring = "Data source = DESKTOP-C16M4NE\SQLEXPRESS;initial catalog=AAJIHRD;user=sa;password=alumuniumferum"
  15. con = New SqlConnection(constring)
  16.  
  17. Try
  18. If con.State = ConnectionState.Closed Then
  19. con.Open()
  20. End If
  21. Return True
  22. Catch ex As Exception
  23. MsgBox(ex.Message)
  24. Return False
  25. End Try
  26. End Function
  27.  
  28. Sub tampil_menu()
  29. Dim i As Integer = 1
  30. Dim x_pos, y_pos As Integer
  31. Try
  32. x_pos = 0
  33. y_pos = 0
  34. query = "SELECT Nama_menu from HRMstMenu"
  35. cmd = New SqlCommand(query, con)
  36. dr = cmd.ExecuteReader()
  37.  
  38. While dr.Read()
  39. Dim btn As New Button
  40.  
  41. btn.Name = "BtnMenu" & i
  42. btn.Text = dr("Nama_menu").ToString()
  43. btn.Location = New Point(x_pos, y_pos)
  44. Form1.Controls.Add(btn)
  45. i = i + 1
  46. y_pos = y_pos + 50
  47. End While
  48. Catch ex As Exception
  49. MsgBox(ex.Message)
  50. End Try
  51.  
  52. End Sub
  53.  
  54. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement