-
[2008] Update Error
I was just curious if anyone can see what may be wrong with the format of my following code. I don't get an error, but nothing happens with the data in the Access Database.
Code:
Using conn As New OleDbConnection(My.Settings.dcConn)
Using update As New OleDbCommand("UPDATE events SET title = @title, event_date = @event_date, time_start = @time_start, time_end = @time_end, location = @location, description = @description WHERE event_id = @event_id", conn)
update.Parameters.AddWithValue("@event_id", ep.event_id)
MessageBox.Show(ep.event_id)
update.Parameters.AddWithValue("@title", txtTitle.Text)
update.Parameters.AddWithValue("@event_date", Format(frmEventsManage.Calendar.SelectionRange.Start, "MM/d/yyyy"))
update.Parameters.AddWithValue("@time_start", Format(dtpStart.Value, "h:mm tt"))
If dtpEnd.Checked = True Then
update.Parameters.AddWithValue("@time_end", Format(dtpEnd.Value, "h:mm tt"))
ElseIf dtpEnd.Checked = False Then
update.Parameters.AddWithValue("@time_end", DBNull.Value)
End If
update.Parameters.AddWithValue("@location", txtLocation.Text)
update.Parameters.AddWithValue("@description", txtDescription.Text)
conn.Open()
update.ExecuteNonQuery()
End Using
End Using
-
Re: [2008] Update Error
Test the return value of ExecuteNonQuery. If it's zero then there's no such ID. If it's not zero then the change IS being saved and you should follow the second link in my signature to see likely reason that you're not seeing it.
-
Re: [2008] Update Error
So, it says 0. But how is that possible when the id DOES exist?
I know that ep.event_id is holding the ID i want because I have a messagebox popup with that value.