Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.SqlClient
- Module Module1
- Public query As String
- Public con As SqlConnection
- Public ds As DataSet
- Public da As SqlDataAdapter
- Public cmd As SqlCommand
- Public dr As SqlDataReader
- Function koneksi() As Boolean
- Dim constring As String
- constring = "Data source = 192.168.88.4;initial catalog=AAJIHRD;user=hrd_usr;password=zxcv4321"
- 'constring = "Data source = DESKTOP-C16M4NE\SQLEXPRESS;initial catalog=AAJIHRD;user=sa;password=alumuniumferum"
- con = New SqlConnection(constring)
- Try
- If con.State = ConnectionState.Closed Then
- con.Open()
- End If
- Return True
- Catch ex As Exception
- MsgBox(ex.Message)
- Return False
- End Try
- End Function
- Sub tampil_menu()
- Dim i As Integer = 1
- Dim x_pos, y_pos As Integer
- Try
- x_pos = 0
- y_pos = 0
- query = "SELECT Nama_menu from HRMstMenu"
- cmd = New SqlCommand(query, con)
- dr = cmd.ExecuteReader()
- While dr.Read()
- Dim btn As New Button
- btn.Name = "BtnMenu" & i
- btn.Text = dr("Nama_menu").ToString()
- btn.Location = New Point(x_pos, y_pos)
- Form1.Controls.Add(btn)
- i = i + 1
- y_pos = y_pos + 50
- End While
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement