33

ADO.NET DataRow - check for column existence

The accepted answer is factually incorrect; one can simply call

row.Table.Columns.Contains(name);

What should be done?

10
  • 3
    Man ... that comment was not enough "Never write ... ? true : false" you should have just edited the code.
    – waffles
    Feb 7, 2011 at 23:21
  • Also ... that question has two duplicate answers, @Gaurav and @Wyatt have exactly the same answer, @Wyatt had his first but it is a lot less useful cause it has no code sample. I kind of want to delete @Wyatt's answer cause it really adds nothing, but he was first. The conundrum
    – waffles
    Feb 7, 2011 at 23:38
  • 2
    @waffles just delete them and change the accepted answer. Don't worry I won't tell anyone it was you
    – Earlz
    Feb 7, 2011 at 23:43
  • 1
    @waffles#1: I tend to respect answerers' code (even when wrong or bad). Maybe I shouldn't.
    – SLaks
    Feb 8, 2011 at 1:49
  • 2
    @Earlz: Even ♦mods cannot force acceptance.
    – SLaks
    Feb 8, 2011 at 4:03
  • 2
    @drchenstern ... chances are slim that I will start messing around with the db just to push my personal agenda, not likely to happen ever.
    – waffles
    Feb 8, 2011 at 4:58
  • @waffles, oh yea, all that red tape. You should make friends with a developer :)
    – Earlz
    Feb 8, 2011 at 22:52
  • 1
    Surely the ? true : false doesn't cause any real problems. Why would you call it "blatantly wrong"? It works, doesn't it, silly and superfluous as it may be.
    – TRiG
    Jul 17, 2015 at 11:15
  • 2
    @TRiGisTimothyRichardGreen: You're seeing the new accepted answer, after the answer this question asked about was deleted. The original accepted answer, which you can see when you get 10K reputation, was a 20-line monstrosity with a DataReader and a for loop.
    – SLaks
    Jul 17, 2015 at 14:10
  • Ah. That makes this conversation somewhat more intelligible.
    – TRiG
    Jul 17, 2015 at 14:19

5 Answers 5

43

Your options are:

  • Downvote it
  • Comment on it and on the question, hope people read your comments.
  • Edit away and fix stuff
  • Flag it
  • Post a question on meta asking for people to downvote it :)*

As a moderator:

  • You can delete in extreme cases (e.g.: how do I rotate my photos: accepted answer format c:)

Here is a list of similar questions (questions that have accepted negatively scoring answers)

https://data.stackexchange.com/stackoverflow/s/903/questions-with-accepted-answers-that-have-a-negative-score

This topic has been covered quite extensively; though I am not sure it is quite resolved. See:

* This is a joke. Meta shouldn't be used to target specific posts or users. For more information, see this question

8
  • 4
    Can someone modify that query to make it so that questions with accepted answers and a negative score and few or no upvotes is shown? Right now most of these are just controversial/subjective answers.
    – Earlz
    Feb 7, 2011 at 23:31
  • This is a good example: stackoverflow.com/questions/163834/php-templates-with-php/… :)
    – Earlz
    Feb 7, 2011 at 23:35
  • here is another: stackoverflow.com/questions/2872543/printf-vs-cout-in-c/… ... there are plenty in that list
    – waffles
    Feb 7, 2011 at 23:52
  • So what do I do in this case, as this answer is accepted, and wrong (at least part of it); moderators are not arbiters of correctness. We should not delete answers because they are blatantly wrong. Nor should they be flagged if they are blatantly wrong (this is why we have the rejection reason "moderators should not be informed of technical inaccuracies, yada yada").
    – casperOne
    Apr 14, 2012 at 13:01
  • @waffles I posted this question asking people to downvote a wrong answer and I got totally nailed: meta.stackexchange.com/questions/139307/… After following the advice on this answer. I'd remove the last point "ask people to downvote" - it doesn't go down well. Jul 11, 2012 at 9:04
  • "hope people read your comments" I would rephrase to something like "put your best effort to make sure people will read your comments"
    – gnat
    Dec 28, 2012 at 13:47
  • 3
    I flagged a blatantly wrong answer and a moderator said declined - flags should not be used to indicate technical inaccuracies, or an altogether wrong answer
    – aug
    Sep 14, 2013 at 4:11
  • 1
    Blatantly wrong answers have the potential to damage SO. People come here for right answers. Truly provably wrong ones do no good for anyone (except possibly rep farmers).
    – david.pfx
    Mar 15, 2014 at 22:32
17

Downvote the ​​​​​​​​​​answer?

5
  • 27
    Downvote squad... GO!
    – Pekka
    Feb 7, 2011 at 23:24
  • 1
    Comment angrily :@
    – bobobobo
    Feb 8, 2011 at 1:38
  • 2
    That wasn't actually what I was asking for. (and 16 downvotes might be a little excessive)
    – SLaks
    Feb 8, 2011 at 1:48
  • 3
    Actually the new best answer is "post to meta.. and the problem will take care of itself."
    – bobobobo
    Feb 8, 2011 at 3:40
  • Downvoting wrong but popular answers may very well not have much of an effect, because most users who arrive at the question by definition don't quite know how to answer it, and likely can't tell that the most popular answer is in fact wrong, and will upvote it. Here's an example. Mar 6, 2014 at 7:54
11
  • Downvote the answer
  • Consider editing the answer if you are absolutely certain it's wrong and your information is correct (ie, it's not just a different way of doing it, it will fail completely)
  • Add a new answer with the correct information or upvote the correct answer
  • Add a comment to the wrong accepted answer with the correction
  • Add a comment to the question requesting the OP re-evaluate their choice for accepted answer
7

(This is mostly a response to waffles.) So, wait... I hate wrong accepted answers as much as the next guy, but I thought that awarding the checkmark was the asker's privilege. If it's going to be "the asker's privilege unless a bunch of people in comments and/or on MSO agree that it's wrong," then where do you draw the line? What if a lot of people complain, but there are people supporting the OP, too?

I'm not against changing truly terrible accepted answer marks, but we should have some sort of system in place for it. Doing it on an ad-hoc basis will eventually cause more problems than it solves.

Also... here's another one.

5
  • 1
    Lol for your another one boils down to "hmm. You seem to be using X IDE, you should use Y IDE. All your programs will work in Y, completely bug free!"
    – Earlz
    Feb 8, 2011 at 0:14
  • I assume your response was to "If it is really really really dangerous delete it?". If so, the number of "really"s seems to indicate he means patently insane things, like Q: "How do I do this thing in C?", A: "Just run rm -rf / on the command-line" Feb 8, 2011 at 0:28
  • 1
    I would not consider this an extreme enough case for deletion ... stackoverflow.com/questions/911536/… ... though personally I wish it was deleted
    – waffles
    Feb 8, 2011 at 1:08
  • @Pops: The easy place to draw the line is at the point where the accepted answer gets offensive-deleted...
    – Shog9
    Feb 8, 2011 at 1:19
  • The question is moot. Even ♦mods cannot force acceptance.
    – SLaks
    Feb 8, 2011 at 4:02
1

Post a bounty to attract more attention. Hopefully this bounty will draw at least one better answer (if one hasn't been contributed yet).

Then award the bounty to a better answer.

(I haven't made up my mind what I think about this yet; I'm posting this here since it's the solution I've picked up through SE folklore, and I was surprised not to find this option posted here yet.)

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .