Reputation: 231
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.
Upvotes: 1
Views: 466
Reputation: 51504
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;
Upvotes: 3