Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ReadTable()
- Dim connection As SqlConnection
- Try
- connection = New SqlConnection("connection_string")
- connection.Open()
- Dim command As SqlCommand = connection.CreateCommand
- command.CommandText = "SELECT NamaField FROM NamaTabel"
- Dim reader As SqlDataReader = command.ExecuteReader
- While reader.Read
- 'code menggunakan reader(0).ToString
- End While
- reader.Close()
- command.Dispose()
- Catch ex As Exception
- 'menampilkan error
- MsgBox(ex.Message)
- Finally
- 'code yang akan selalu dieksekusi
- connection.Close()
- End Try
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement