1
public void UpdateRegistration(User userModel)
    {
        using (IDbConnection connection = BaseRepository.OpenConnection())
        {
            string query = "UPDATE [dbo].[TBUser] " +
                "(CreatedBy, CreatedDate, ModifiedBy, ModifiedDate) VALUES " +
                "(@CreatedBy, @CreatedDate, @ModifiedBy, @ModifiedDate) WHERE " +
                "UserId = @UserId;";
            connection.Execute(query, userModel);
        }
    }

I get the following exception while it runs

<Message>An error has occurred.</Message>
<ExceptionMessage>Incorrect syntax near '('.</ExceptionMessage>
<ExceptionType>System.Data.SqlClient.SqlException</ExceptionType>

userModel has all of the properties associated with it.

1 Answer 1

3

The syntax is

UPDATE [table]
SET [field] = Value
WHERE ....

See http://technet.microsoft.com/en-us/library/ms177523.aspx

So your query should be

UPDATE [dbo].[TBUser] 
SET CreatedBy = @CreatedBy, 
    CreatedDate = @CreatedDate,
    ModifiedBy = @ModifiedBy,
    ModifiedDate = @ModifiedDate
WHERE UserId = @UserId;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.