Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Syntax error in UPDATE statement

    The following code generates an error and I am not sure why. Anyone have any ideas?

    cmdString2 = string.Format( "UPDATE USERS SET password='" & txtConfirmPassword.Text & "' WHERE username='" & dtrResults("username") & "'")

    cmdUpdate = New OleDbCommand( cmdString2, conLogin2 )

    conLogin2.Open()
    cmdUpdate.ExecuteNonQuery()
    conLogin2.Close()

    When I display the update statement it looks like this:

    UPDATE USERS SET password='pswrd' WHERE username='usrname'

    I am pretty sure that is ok, but it errors out on the line cmdUpdate.ExecuteNonQuery()

    Thank you for any advice.

    cbowen2

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Try adding squar brackets '[]' around the password field, as i'm sure it's a reserved word:
    Code:
    cmdString2 = string.Format( "UPDATE USERS SET [password]='" & txtConfirmPassword.Text & "' WHERE username='" & dtrResults("username") & "'")
    Good luck
    Last edited by Brandoe85; 07-26-2005 at 08:35 PM.

  • #3
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank You!

    You are a life saver, thank you very much!

  • #4
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks

    thank you Brando

    that is also my problem and when i read it i put a bracket on every field i want to update

  • #5
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanx ! really this is a big problem.very thanx.


    http://homefitnessandnutrition.co.cc...cycling-skill/

  • #6
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    I have a similar problem..,,this is my code

    Dim cb As New OleDb.OleDbCommandBuilder(da)

    ds.Tables("Inventory").Rows(inc).Item(0) = txtProductName.Text
    ds.Tables("Inventory").Rows(inc).Item(1) = txtRefNumber.Text
    ds.Tables("Inventory").Rows(inc).Item(2) = txtCategory.Text
    ds.Tables("Inventory").Rows(inc).Item(3) = txtQuantity.Text
    ds.Tables("Inventory").Rows(inc).Item(5) = txtLotNumber.Text

    da.Update(ds, "Inventory")

    MsgBox("Data updated")
    End Sub


    Im able to run my Form, just when I want to update the changes made into the field "Lot Number" I get the same error.

    Any help?


  •  

    Posting Permissions

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