Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Imports System.Data
  2. Imports System.Data.SqlClient
  3.  
  4. Public Class DB
  5. Dim con As SqlConnection
  6. Dim cmd As SqlCommand
  7.  
  8. Dim i As Integer
  9.  
  10. Public Sub New()
  11. con = New SqlConnection("server=DESKTOP-M9MDGJN\SQLEXPRESS; database=testdb; integrated security=true")
  12.  
  13. End Sub
  14.  
  15. Public Function doInsert(vSQL As String)
  16. doOpen()
  17.  
  18. cmd = New SqlCommand(vSQL, con)
  19. i = cmd.ExecuteNonQuery()
  20.  
  21. doClose()
  22.  
  23. Return 0
  24. End Function
  25.  
  26. Public Function doUpdate(vSQL As String)
  27. doOpen()
  28.  
  29. cmd = New SqlCommand(vSQL, con)
  30. i = cmd.ExecuteNonQuery()
  31.  
  32. doClose()
  33.  
  34. Return 0
  35. End Function
  36.  
  37.  
  38. Public Function doDelete(vSQL As String)
  39. doOpen()
  40.  
  41. cmd = New SqlCommand(vSQL, con)
  42. i = cmd.ExecuteNonQuery()
  43.  
  44. doClose()
  45.  
  46. Return 0
  47. End Function
  48. Public Function doRetrieve(vSQL As String) As SqlDataReader
  49.  
  50. Dim rs As SqlDataReader
  51.  
  52. doOpen()
  53.  
  54. cmd = New SqlCommand(vSQL, con)
  55. rs = cmd.ExecuteReader()
  56.  
  57. Return rs
  58. End Function
  59.  
  60. Private Function doOpen()
  61. con.Open()
  62. End Function
  63. Private Function doClose()
  64. con.Close()
  65. Return 0
  66. End Function
  67. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement