tpra21
Active member
- Joined
- Oct 21, 2006
- Messages
- 26
- Programming Experience
- 1-3
In the code below, I have two textboxes and a combo box all bound to columns in the Reminders table. My ADD and UPDATE buttons work perfect, and refresh the data in my bound controls afterward. I cannot for the life of me get my DELETE button to refresh my bound controls after I click the delete button and delete a row. The deleted row is still in my controls until I exit from the form and reenter. I have tried clearing the data set, re-filling, etc. I cannot get anything to work. Any ideas would be great.
VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'Delete the record from the database
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].OleDbDeleteCommand1.CommandText = "DELETE * FROM Reminders WHERE (ReminderID = ?)"
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].OleDbDeleteCommand1.Connection = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].OleDbConnection2
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].OleDbDeleteCommand1.Parameters.Add("@ReminderID", System.Data.OleDb.OleDbType.Integer, 0, "ReminderID").Value = ComboBox1.SelectedValue
[/SIZE][SIZE=2][COLOR=#008000]'Give a warning message and ask for confirmation
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] result [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DialogResult = _
MessageBox.Show("Delete the Reminder ?", "Confirm Deletion", _
MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)
[/SIZE][SIZE=2][COLOR=#008000]'If yes is entered on message, delete the record
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] result = DialogResult.Yes [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2]OleDbConnection2.Open()
OleDbDeleteCommand1.ExecuteNonQuery()
[/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception
MessageBox.Show(ex.Message)
[/SIZE][SIZE=2][COLOR=#0000ff]Finally
[/COLOR][/SIZE][SIZE=2]OleDbConnection2.Close()
MessageBox.Show("The Record Has Been Deleted", "Reminder Deleted", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].OleDbDataAdapter1.Fill([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Reminders1)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE]