SQL Server表未更新

时间:2015-09-05 10:34:27

标签: c# sql-server

using (SqlCommand command = new SqlCommand(
 "WITH CTE AS (SELECT ROW_NUMBER() OVER (ORDER BY ID) AS RowNumber, Name, Website, Username, Password, Extras, CategoryIn" +
 "FROM Accounts WHERE CategoryIn = @category) " +
 "UPDATE CTE SET Name = @name, Website = @website, Username = @username, Password = @password, Extras = @extras, CategoryIn = @category WHERE RowNumber = @id", connection))
{ 
    connection.Open();

    command.Parameters.AddWithValue("@category", category);
    command.Parameters.AddWithValue("@id", id);
    command.Parameters.AddWithValue("@name", name);
    command.Parameters.AddWithValue("@website", website);
    command.Parameters.AddWithValue("@username", username);
    command.Parameters.AddWithValue("@password", password);
    command.Parameters.AddWithValue("@extras", extras);

    command.ExecuteNonQuery();
}

我有一些代码来更新表,除了列CategoryIn之外,它还可以更新。我猜它与CTE和WHERE CategoryIn = @category部分有关。有人可以指点我吗?

0 个答案:

没有答案