During my table I've many rows with data. One row has seven posts with values.

Can you really remove in one row values of two posts and relaxation five leave without changes?

Can One into it with SQL remove?

   cmd.CommandText = @"DELETE ImageData,"
                     + " ContentType,  "
                     + " FROM Users "
                     + " WHERE UserName = @UserName";

    cmd.Parameters.Add(new SqlParameter("@UserName", username));
    cmd.Parameters.Add(new SqlParameter("@ImageData", ImageData));
    cmd.Parameters.Add(new SqlParameter("@ContentType", ContentType));

During my code I can not remove such as this, could it be wrong? Does anybody understand how to remove them?

I suppose it isn't DELETE you'll need but UPDATE.

  • DELETE always removes a whole row.
  • UPDATE enables you to definitely change individual posts consecutively.


@"UPDATE Users "
  + "SET ContentType = NULL, "
  + "    ImageData = NULL "
  + "WHERE Username = @UserName";

You should utilize an UPDATE statement with this. DELETE is just for removing whole row(s) at any given time.

You cannot really "remove" them as if it had been cells inside a spreadsheet though. Presuming the posts are nullable you are able to set these to NULL as below.

cmd.CommandText = @"UPDATE ImageData
                    SET ContentType = NULL, Users = NULL
                    WHERE UserName = @UserName";

            cmd.Parameters.Add(new SqlParameter("@UserName", username));

you can update the row:

SET ImageData = NULL, ContentType = NULL
WHERE UserName = @UserName