Results 1 to 4 of 4

Thread: [RESOLVED] Update statement

  1. #1

    Thread Starter
    Member wietmie's Avatar
    Join Date
    Aug 2008
    Posts
    49

    Resolved [RESOLVED] Update statement

    Hai All.. can someone explain to me what is going on with my code? i think it's ok enough..

    Code:
    strSQL = "UPDATE tblUser SET User = '" & UCase(txtUser.Text) & "', fName = '" & UCase(txtfName.Text) & "', lName = '" & UCase(txtlName.Text) & "', Question = '" & UCase(comboQuestion.Text) & "', Secret = '" & UCase(txtSecret.Text) & "' WHERE User = '" & UserName & "'"
        MsgBox strSQL
        Set mobjCmd = New ADODB.Command
        Set mobjCmd.ActiveConnection = conn
        mobjCmd.CommandType = adCmdText
        mobjCmd.CommandText = strSQL
        mobjCmd.Execute
        MsgBox "Update Successful", vbInformation, "Success"
    This code is to update an existing record, the error return was:

    Code:
    Syntax error in update statement
    An Ordinary Person With An Extraordinary Determination

  2. #2
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Update statement

    Hmm can try wrapping "user" in [] so it becomes "[User]" i believe user is a reserved word so it will cause complications if you don't wrap it in brackets.

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Update statement

    Do you have any single quotes in there? Like last name = O'Brien. Even if you don't in the case I'd change that to:

    Replace(UCase(txtlName.Text),"'","''")

  4. #4

    Thread Starter
    Member wietmie's Avatar
    Join Date
    Aug 2008
    Posts
    49
    Yes.. problem solve, thanks a lot. wrap it with bracket is all the solution.
    An Ordinary Person With An Extraordinary Determination

Posting Permissions

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



Click Here to Expand Forum to Full Width