Advertisement
binjeeclick

error

Nov 25th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.66 KB | None | 0 0
  1. Sub ReadTable()
  2.    Dim connection As SqlConnection
  3.     Try
  4.         connection = New SqlConnection("connection_string")
  5.         connection.Open()
  6.         Dim command As SqlCommand = connection.CreateCommand
  7.         command.CommandText = "SELECT NamaField FROM NamaTabel"
  8.         Dim reader As SqlDataReader = command.ExecuteReader
  9.         While reader.Read
  10.             'code menggunakan reader(0).ToString
  11.         End While
  12.         reader.Close()
  13.         command.Dispose()
  14.     Catch ex As Exception
  15.         'menampilkan error
  16.         MsgBox(ex.Message)
  17.     Finally
  18.         'code yang akan selalu dieksekusi
  19.         connection.Close()
  20.     End Try
  21. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement