Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
| Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 20th, 2006, 08:20 AM
Authorized User
 
Join Date: Aug 2006
Location: Mumbai, Maharashtra, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to amit_mande@yahoo.com Send a message via AIM to amit_mande@yahoo.com Send a message via MSN to amit_mande@yahoo.com Send a message via Yahoo to amit_mande@yahoo.com
Default I solved insert query.now see this Update Query.

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?

  #2 (permalink)  
Old September 20th, 2006, 03:08 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

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
Code:
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
Code:
Private Sub cmdUpdate_Click(ByVal sdr As System.Object, _
Code:
                            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   "
                                ?
  #3 (permalink)  
Old September 21st, 2006, 12:48 AM
Authorized User
 
Join Date: Aug 2006
Location: Mumbai, Maharashtra, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to amit_mande@yahoo.com Send a message via AIM to amit_mande@yahoo.com Send a message via MSN to amit_mande@yahoo.com Send a message via Yahoo to amit_mande@yahoo.com
Default

Ya Its Working.Thanks.



Similar Threads
Thread Thread Starter Forum Replies Last Post
SOLVED...VBA and Update Query eusanpe Access VBA 8 June 2nd, 2008 08:48 AM
Insert query problem. -- Solved rupen Classic ASP Basics 5 May 15th, 2007 08:59 AM
New Insert Query Neal SQL Server 2000 3 May 8th, 2007 01:22 PM
INSERT Query Neal SQL Server 2000 2 May 3rd, 2007 05:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.