MS Access Update Programaticly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • praclarush
    New Member
    • Oct 2007
    • 27

    #1

    MS Access Update Programaticly

    I'm trying to connect to a access database and post an update to a row in a table though code with Visual Basic 2005, but when I do, I'm getting a Syntax error with the update statment. I don't understand what I'm doing wrong since the update statment looks like one that would be generated by Visual Studio when working with datasets

    Code:
    Private Sub UpdateTest()
            Try
                Using Conn As OleDbConnection = New OleDbConnection(My.Settings.BalanceAssistConnectionString)
                    Conn.Open()
                    Try
                        Using Com As OleDbCommand = Conn.CreateCommand
                            Com.CommandType = CommandType.Text
                            Com.CommandText = "Update MultiParam Set Phone = ?, Set WorkName = ? Where Name = ?"
    
                            
                            Com.Parameters.AddWithValue("Phone", txtPhone.Text)
                            Com.Parameters.AddWithValue("WorkName", txtWorkName.Text)
                            Com.Parameters.AddWithValue("Name", txtName.Text)
                            Com.ExecuteNonQuery()
                        End Using
                    Catch ex As Exception
                        MessageBox.Show(ex.ToString, "Error With Insert")
                    End Try
                    Conn.Close()
                End Using
            Catch ex As Exception
                MessageBox.Show("Could Not Open Connection To Database" & ex.ToString, "Connection Error")
            End Try
            MessageBox.Show("Update Complete")
    
        End Sub
    Any help would be great,
    Thanks Nathan
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Greetings, praclarush!

    I don;t want to tell you to start from scratch, this looks like a nicely written code. But I wanted to point you to Micorsoft's siote for readily available videos you can use to achieve the very tasks you are referring to, with Datasets and all:

    Visual Basic How Do I Video Series

    Of course, you'll need to search the examples a bit, but you should be all set:-)

    Happy New Year!

    Dököll
    Last edited by Dököll; Jan 1 '09, 02:21 AM. Reason: Microsoft's for Micorsoft's...

    Comment

    Working...