11-25-2012, 11:47 PM
Thanks for your response - really appreciate it. While waiting, I started playing around and managed to come up with this after watching a couple of Youtube videos and searching online:
HERE'S MY SOLUTION - PLEASE CRITIQUE IT:
[code2=vbnet]Private Sub ButtonDelete_Click(sender As System.Object, e As System.EventArgs) Handles ButtonDelete.Click
'FOR MySQL DATABASE USE
Dim dbConn As New MySqlConnection(String.Format("Server={0};Port={1};Uid={2};Password={3};Database=accounting", FormLogin.ComboBoxServerIP.SelectedItem, My.Settings.DB_Port, My.Settings.DB_UserID, My.Settings.DB_Password))
Dim dbTable As New DataTable
Dim dbQuery As String = ""
'Dim dbCmd As New MySqlCommand
Dim confirmation As DialogResult = MessageBox.Show("This action will delete the selected Customer Credit Cards from the database.", "Are you sure?", MessageBoxButtons.YesNo)
If (confirmation = Windows.Forms.DialogResult.Yes) Then
'Delete Records
Try
If ListViewRecords.Items.Count > 0 Then
For i = ListViewRecords.Items.Count - 1 To 0 Step -1
If ListViewRecords.Items(i).Checked = True Then
dbQuery = "DELETE FROM cc_master WHERE ccID = '" & ListViewRecords.Items(i).Text & "'"
Dim dbAdapter As New MySqlDataAdapter(dbQuery, dbConn)
dbAdapter.Fill(dbTable)
Call getRecordCount()
Call loadRecords()
End If
Next i
End If
Catch ex As Exception
MessageBox.Show("A DATABASE ERROR HAS OCCURED" & vbCrLf & vbCrLf & ex.Message & vbCrLf & _
vbCrLf + "Please report this to the IT/Systems Helpdesk at Ext 131.")
End Try
dbConn.Close()
dbConn.Dispose()
End If
End Sub[/code2]
HERE'S MY SOLUTION - PLEASE CRITIQUE IT:
[code2=vbnet]Private Sub ButtonDelete_Click(sender As System.Object, e As System.EventArgs) Handles ButtonDelete.Click
'FOR MySQL DATABASE USE
Dim dbConn As New MySqlConnection(String.Format("Server={0};Port={1};Uid={2};Password={3};Database=accounting", FormLogin.ComboBoxServerIP.SelectedItem, My.Settings.DB_Port, My.Settings.DB_UserID, My.Settings.DB_Password))
Dim dbTable As New DataTable
Dim dbQuery As String = ""
'Dim dbCmd As New MySqlCommand
Dim confirmation As DialogResult = MessageBox.Show("This action will delete the selected Customer Credit Cards from the database.", "Are you sure?", MessageBoxButtons.YesNo)
If (confirmation = Windows.Forms.DialogResult.Yes) Then
'Delete Records
Try
If ListViewRecords.Items.Count > 0 Then
For i = ListViewRecords.Items.Count - 1 To 0 Step -1
If ListViewRecords.Items(i).Checked = True Then
dbQuery = "DELETE FROM cc_master WHERE ccID = '" & ListViewRecords.Items(i).Text & "'"
Dim dbAdapter As New MySqlDataAdapter(dbQuery, dbConn)
dbAdapter.Fill(dbTable)
Call getRecordCount()
Call loadRecords()
End If
Next i
End If
Catch ex As Exception
MessageBox.Show("A DATABASE ERROR HAS OCCURED" & vbCrLf & vbCrLf & ex.Message & vbCrLf & _
vbCrLf + "Please report this to the IT/Systems Helpdesk at Ext 131.")
End Try
dbConn.Close()
dbConn.Dispose()
End If
End Sub[/code2]
//Kismet