Results 1 to 3 of 3

Thread: [2008] Update Error

  1. #1

    Thread Starter
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    [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

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    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.
    Last edited by Seraph; Dec 16th, 2008 at 08:38 PM.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width