Hi all

With the following SQL " Dim Query As String = "UPDATE JobName_tbl SET [JobDate]=@NewDATE, JobAddress=@Newaddress Where JobID=@ID"
nothing happens nothing gets updated nor do I get an error.
But as soon as I remove the [JobDate]=@NewDATE, it works fine.
Hope someone can help me with this situation.
Here is my code:
Thank You

Public Sub UpdateAddress(ByVal JobID As Integer, ByVal JobUpdate As String, ByVal NewDate As Date)
        Try            
            Dim Query As String = "UPDATE JobName_tbl SET [JobDate]=@NewDATE, JobAddress=@Newaddress Where JobID=@ID"    
            Dim DBcon As New DBConnection.Connection
            DBcon.FilePath = "C:\CFI\Filepath.txt"
            DBcon.connect()
            DBcon.con.Open()
           Dim cmd As New OleDb.OleDbCommand(Query, DBcon.con)
                With cmd
                .CommandType = CommandType.Text
                .CommandText = Query
                .Parameters.AddWithValue("@Newaddress", JobUpdate)
                .Parameters.AddWithValue("@ID", JobID)
                .Parameters.AddWithValue("@NewDATE", NewDate)
                .ExecuteNonQuery()
            End With
            DBcon.con.Close()
        Catch ex As Exception
            MsgBox("JobAddress_UpdateAddress" & ex.Message)
        End Try
    End Sub

Recommended Answers

All 3 Replies

What happens if you just remove the brackets from JobDate [] ?

A good step in debugging something like this is to get the actual statement and either run it in the db or at least go through it.

use debug.print cmd.commandtext just before the ExecuteNonQuery and verify that you are running what you think you are.

A good step in debugging something like this is to get the actual statement and either run it in the db or at least go through it.

use debug.print cmd.commandtext just before the ExecuteNonQuery and verify that you are running what you think you are.

Thanks All for your help but I solved it by putting the .Parameters.AddWithValue in the same order as in the query.
:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.