Item removing from MySQL via Visual Basic

In the project I still making I’m using MySQL database to storing items. We can remove items from database. How to remove item from MySQL via Visual Basic?

Attention! This post has been published on my old website that has been down. I’m archiving old not verified posts for possible future use. Please be careful when using this post content.

In order to remove item from MySQL table following query has to be used:

DELETE FROM TableName WHERE DB_ColumnName='YourRecord';

Following code is consisted of:

  • MySqlConnection – connection to MySQL database,
  • MySqlDataAdapter – query to MySQL,
  • Try – trying open connection,
  • Exception – error handling.

Whole code to connect MySQL database and remove some item:

Imports MySql.Data.MySqlClient

Public Sub UsunLokacje()
' Item removing from MySQL database

Dim dTableCount As Long
Dim dTable1 As New DataTable

'1. Connection data
Dim conn As MySqlConnection = New MySqlConnection() ' forgot source
conn.ConnectionString = "Data Source=" & fmMain.txtMYSQLpath.Text & "; Database=" & fmMain.txtOPCJEnazwaMYSQL.Text & _
    "; Uid=root; Pwd=" & fmMain.txtOPCJEhasloMYSQL.Text & ";"


    conn.Open() ' open connection

        ' Checking if item is in table
        ' -----------------------------------------
        Dim adapter As MySqlDataAdapter = New MySqlDataAdapter("SELECT * FROM nazwylokacji WHERE Lokacja='" & _
                                         fmMain.txtOPCJETornadoLokacja.Text & "';", conn)

        adapter.Fill (dTable1)
        dTableCount = dTable1.Rows.Count
        If dTableCount > 0 Then
            ' Item removing
            ' ---------------------------------
            Dim cmd1 As MySqlCommand = New MySqlCommand("DELETE FROM nazwylokacji WHERE Lokacja='" & _
                                         fmMain.txtOPCJETornadoLokacja.Text & "';", conn)
            cmd1.ExecuteNonQuery() 'usuwanie wartości z MySQL
            cmd1 = Nothing
            ' Confiramtion for user
            ' -------------------------------------------------
            MsgBox("Location '" & fmMain.txtOPCJETornadoLokacja.Text & "' has been removed.", vbInformation, "Confirmation...")
            MsgBox("Location can't be removed: '" & fmMain.txtOPCJETornadoLokacja.Text & "'.", vbCritical, "Error...")
        End If
    Catch ex1 As Exception
        MsgBox("Error when location removing. Table: 'nazwylokacji'." + Chr(10) + Chr(10) + "Err no.:" + Chr(10) + ex1.Message, _
       MsgBoxStyle.Critical, "Error...")
    End Try

Catch ex As Exception

    MsgBox("Database connection problem. Table: 'nazwylokacji'." + Chr(10) + Chr(10) + "Kod błedu:" + Chr(10) + ex.Message, _
        MsgBoxStyle.Critical, "Conenction error...")

    Call modDBgrid.IloscTornado   ' DataGridView refresh
End Try

End Sub

173 thoughts on “Item removing from MySQL via Visual Basic

  1. Pingback: soi lo de

  2. Pingback: cach choi number game

  3. Pingback: buy lortab pills online pharmacy no presption next day shipping discreet

  4. Pingback: mo thay nguoi chet danh con gi

  5. Pingback: order ativan online in usa canada uk australia without prescription nextday shipping

  6. Pingback: danh de online uy tin

  7. Pingback: gomovies-online

  8. Pingback: con cho so may

  9. Pingback: bitcoin evolution review

  10. Pingback: UNIQCC

  11. Pingback: is blazing trader a scam?

  12. Pingback: Making Money Online

  13. Pingback: Hotels in San Diego

  14. Pingback: buy/order Tangie OG Cannabis Oil online use for pain, anxiety, sleep for sale near me bulk in usa uk nz canada australia overnight delivery

  15. Pingback: eatverts

  16. Pingback: More Help

  17. Pingback: thenaturalpenguin

  18. Pingback: buy roxicodone 5 mg for sale overnight delivery cheap

  19. Pingback: pinewswire

  20. Pingback: English bulldog puppies for sale near me in MN MD CT NJ AZ AK LA WV ND IW NC NB WA NV MI

  21. Pingback: bitcoin loophole

  22. Pingback: Immediate Edge Review 2020

  23. Pingback: ریور پوکر

  24. Pingback: mơ thấy anh em gặp nhau

  25. Pingback: mơ thấy con mèo đánh con gì

  26. Pingback: mơ thấy xe tải

  27. Pingback: mơ mình chết đánh con gì

  28. Pingback: Pinball Machines for Sale

  29. Pingback: labradoodle puppies for sale near me

  30. Pingback: nằm mơ thấy mình bay lơ lửng

  31. Pingback: interqq

  32. Pingback: mo ran can

  33. Pingback: nằm mơ thấy sập nhà

  34. Pingback: Earn Fast Cash Now

  35. Pingback: mơ thấy bị bắn

  36. Pingback: mơ thấy cóc đánh con gì

  37. Pingback: XFINITY Store by Comcast

  38. Pingback: DevOps Consulting Services

  39. Pingback: nằm mơ thấy chó đẻ con

  40. Pingback: nằm mơ thấy mẹ bị bệnh

  41. Pingback: mơ thấy người nổi tiếng

  42. Pingback: dơi bay vào nhà tốt hay xấu

  43. Pingback: mơ thấy xe máy đánh con gì

  44. Pingback: nhân mã nam và nhân mã nữ

  45. Pingback: con số may mắn của ma kết

  46. Pingback: cung song tử hợp với cung nào nhất

  47. Pingback: quả mít là số mấy

  48. Pingback: mơ thấy xương người

  49. Pingback: mơ thấy ác mộng

  50. Pingback: nằm mơ thấy chạy xe đạp

  51. Pingback: mơ thấy người yêu cũ chết

  52. Pingback: buy cialis overnight

  53. Pingback: buy levitra 20mg

  54. Pingback: cialis lethargy

  55. Pingback: viagra women

  56. Pingback: order cialis 20 mg

  57. Pingback: online pharmacy no prescription

  58. Pingback: pharmacy

  59. Pingback: canadian online pharmacies legitimate by aarp

  60. Pingback: erection pills

  61. Pingback: viagra

  62. Pingback: cialis canadian pharmacy

  63. Pingback: viagra cialis combo

  64. Pingback: monthly cost of cialis without insurance

  65. Pingback: cialis buy online

  66. Pingback: buy cialis united kingdom

  67. Pingback: cialis payment with paypal

  68. Pingback: buy cialis shipping canada

  69. Pingback: cialis 5mg tablet

  70. Pingback: cialis brand no prescription 365

  71. Pingback: viagra pills cheap

  72. Pingback: canada cialis online

  73. Pingback: buy cialis tadalafil0 with pay pal

  74. Pingback: cheap generic cialis

  75. Pingback: cialis online without prescription

  76. Pingback: ngecjhph

  77. Pingback: where can i buy kamagra

  78. Pingback: wanneer werkt viagra niet

  79. Pingback: what can zithromax treat

  80. Pingback: buy cialis online in canada

  81. Pingback: cialis e ipertrofia prostatica

  82. Pingback: cialis

  83. Pingback: monthly cost of cialis without insurance

  84. Pingback: canadian viagra

  85. Pingback: cialis 5mg tablet

  86. Pingback: comprar viagra online espaГ±a

  87. Pingback: ordering cialis online australia

  88. Pingback: custom essay writing service uk

  89. Pingback: cialis tadalafil portugal

  90. Pingback: custom research paper writing services

  91. Pingback: what should i write about in my college essay

  92. Pingback: i need help with my college essay

  93. Pingback: business ethics essay thesis statement

  94. Pingback: monthly cost of cialis without insurance

  95. Pingback: antibiotics augmentin

  96. Pingback: lasix 500 mg tab

  97. Pingback: canadian pharmacy azithromycin buy online

  98. Pingback: stromectol pill price

  99. Pingback: 2.5 albuterol

  100. Pingback: prednisolone 5mg uses

  101. Pingback: hcg and clomid

  102. Pingback: buying dapoxetine

  103. Pingback: diflucan thrush

  104. Pingback: synthroid com

  105. Pingback: writing your thesis

  106. Pingback: propecia package insert

  107. Pingback: neurontin 400 mg

  108. Pingback: metformin function

  109. Pingback: paxil 40 mg

  110. Pingback: plaquenil covid 19

  111. Pingback: buy metformin without prescription cheap

  112. Pingback: buy generic propecia

  113. Pingback: buy cialis philippines

  114. Pingback: mens erection pills

  115. Pingback: find cheap cialis online

  116. Pingback: online pharmacy pain

  117. Pingback: Zakhar Berkut hd

  118. Pingback: sure save pharmacy

  119. Pingback: 4569987

  120. Pingback: buy cialis tadalafil0 with pay pal

  121. Pingback: buy cialis online generic

  122. Pingback: 20 mg cost

  123. Pingback: buy cialis online overnight

  124. Pingback: news news news

  125. Pingback: online cash advance downey

  126. Pingback: psy

  127. Pingback: psy2022

  128. Pingback: projectio-freid

  129. Pingback: cialis denavir yasmin retin a

  130. Pingback:

  131. Pingback: payday cash advance hendersonville

  132. Pingback:

  133. Pingback: topvideos

  134. Pingback: video

  135. Pingback: walgreen viagra

  136. Pingback: buy toronto

  137. Pingback: zestril 5 mg prices

  138. Pingback:

  139. Pingback: Ukrainskie-serialy

  140. Pingback: site

  141. Pingback: where can i get cialis over the counter

  142. Pingback: plenty of fish free dating sign in

  143. Pingback: too much cialis

  144. Pingback: viagra and cialis discount

  145. Pingback: buy real ativan online

  146. Pingback: top

  147. Pingback: viagra vs cialis vs levitra cost

  148. Pingback: good canadian pharmacies

  149. Pingback: cialis or levitra

  150. Pingback: buy cialis 36 hour

  151. Pingback: Aspirin

  152. Pingback: buy cialis philippines

  153. Pingback: buy cheap cialis overnight

  154. Pingback: best canadian pet pharmacy

  155. Pingback: generic cialis daily pricing

  156. Pingback: where can i buy cialis without a prescription

  157. Pingback: can i buy cialis in uk

  158. Pingback: cialis 5mg tablet

  159. Pingback: what are ed drugs

  160. Pingback: tadalafil herbal substitute

  161. Pingback: buy valtrex singapore

  162. Pingback: viagra and alcohol

  163. Pingback: ed remedies

  164. Pingback: black cialis c800

  165. Pingback: 100 mg viagra

  166. Pingback: tadalafil generic usa

  167. Pingback: viagra instructions

  168. Pingback: cialis efectos secundarios

  169. Pingback: sildenafil 50 coupon

  170. Pingback: where can i buy viagra over the counter

  171. Pingback: generic cialis 20mg

  172. Pingback: sildenafil price australia

  173. Pingback:

Leave a Reply

Your email address will not be published. Required fields are marked *