Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
  2.  
  3. Dim strSelect As String = ""
  4. Dim strFirstName As String = ""
  5. Dim strLastName As String = ""
  6. Dim strAddress As String = ""
  7. Dim strCity As String = ""
  8. Dim strState As String = ""
  9. Dim strZip As String = ""
  10. Dim strPhoneNumber As String = ""
  11. Dim strEmail As String = ""
  12. Dim intRowsAffected As Integer
  13.  
  14.  
  15. Dim cmdUpdate As OleDb.OleDbCommand
  16.  
  17.  
  18. If Validation() = True Then
  19. ' open database
  20. If OpenDatabaseConnectionSQLServer() = False Then
  21.  
  22. ' No, warn the user ...
  23. MessageBox.Show(Me, "Database connection error." & vbNewLine &
  24. "The application will now close.",
  25. Me.Text + " Error",
  26. MessageBoxButtons.OK, MessageBoxIcon.Error)
  27.  
  28.  
  29. Me.Close()
  30.  
  31. End If
  32.  
  33.  
  34. If Validation() = True Then
  35.  
  36. strFirstName = txtFirstName.Text
  37. strLastName = txtLastName.Text
  38. strAddress = txtAddress.Text
  39. strCity = txtCity.Text
  40. strState = txtState.Text
  41. strZip = txtZip.Text
  42. strPhoneNumber = txtPhoneNumber.Text
  43. strEmail = txtEmail.Text
  44.  
  45.  
  46.  
  47.  
  48. strSelect = "Update TGolfers Set strFirstName = '" & strFirstName & "', " & "strLastName = '" & strLastName &
  49. "', " & "strAddress = '" & strAddress & "', " & "strCity = '" & strCity & "', " &
  50. "strState = '" & strState & "', " & "strZip = '" & strZip & "', " &
  51. "strPhoneNumber = '" & strPhoneNumber & "', " & "strEmail = '" & strEmail & "', " &
  52. "intShirtSizeID = '" & cboShirtSizes.SelectedValue.ToString & "' " &
  53. "intGenderID = '" & cboGenders.SelectedValue.ToString & "' " &
  54. "Where intGolferID = " & cboGolfers.SelectedValue.ToString
  55.  
  56.  
  57.  
  58. MessageBox.Show(strSelect)
  59.  
  60.  
  61.  
  62. cmdUpdate = New OleDb.OleDbCommand(strSelect, m_conAdministrator)
  63.  
  64.  
  65. intRowsAffected = cmdUpdate.ExecuteNonQuery()
  66.  
  67.  
  68. If intRowsAffected = 1 Then
  69. MessageBox.Show("Update successful")
  70. Else
  71. MessageBox.Show("Update failed")
  72. End If
  73.  
  74.  
  75. CloseDatabaseConnection()
  76.  
  77.  
  78. frmManageGolfers_Load(sender, e)
  79. End If
  80. End If
  81.  
  82. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement