Subject: I solved insert query.now see this Update Query.
Posted By: amit_mande@yahoo.com Post Date: 9/20/2006 8:20:53 AM
see this code

 Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
        Dim intPosition As Int16
        myCommand = New OleDbCommand
        intPosition = myCurrencyManager.Position
        myCommand.CommandText = "UPDATE login SET Password=@Password WHERE UserId=@UserId"
        myCommand.Parameters.Add("@UserId", BindingContext(myDataView).Current("UserId"))
        myCommand.Parameters.Add("@Password", txtPassword.Text)
        myCommand.CommandType = CommandType.Text
        myCommand.Connection = myConnection

        myConnection.Open()
        Try
            myCommand.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
        FillDataSetAndView()
        BindFields()

        myCurrencyManager.Position = intPosition
        ShowPosition()

        StatusBar1.Text = "Record Updated"
        myConnection.Close()
    End Sub

The error is "Syntax error in UPDATE Query" Its is catch by try...catch statement
which is correct form of Query?

Reply By: BrianWren Reply Date: 9/20/2006 3:08:18 PM
In my opinion, it would have been good if this had been continued in the thread where it was begun;  that would have made it so that your statements had a context.  Saying in this thread that you fixed something means nothing to those who don't know what you fixed...
For those coming to this new, the original is in http://p2p.wrox.com/topic.asp?TOPIC_ID=49965

____________________ _
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯


Perhaps your query is trying to translate the field name as a keyword.

What happens if you use

Private Sub cmdUpdate_Click(ByVal sdr As System.Object, _
                            ByVal e As System.EventArgs) _
            Handles cmdUpdate.Click

        Dim intPosition As Int16
        intPosition = myCurrencyManager.Position

        myCommand = New OleDbCommand
        myCommand.CommandText = "UPDATE login                      " & _
                                "SET    login.Password = @Password " & _
                                "WHERE  UserId         = @UserId   "
or
Private Sub cmdUpdate_Click(ByVal sdr As System.Object, _
                            ByVal e As System.EventArgs) _
            Handles cmdUpdate.Click

        Dim intPosition As Int16
        intPosition = myCurrencyManager.Position

        myCommand = New OleDbCommand
        myCommand.CommandText = "UPDATE login                         " & _
                                "SET   [login].[Password] = @Password " & _
                                "WHERE [login].[UserId]   = @UserId   "
?
Reply By: amit_mande@yahoo.com Reply Date: 9/21/2006 12:48:06 AM
Ya Its Working.Thanks.


Go to topic 50044

Return to index page 169
Return to index page 168
Return to index page 167
Return to index page 166
Return to index page 165
Return to index page 164
Return to index page 163
Return to index page 162
Return to index page 161
Return to index page 160