11

It seems that there are many questions on the site asking about the common .Net/SQL Server issue where someone's trying to supply a parameter to a a parametrized query, the value is null, and they forget to put DBNull.Value, leading to that issue.

Google shows us a ton of results. Some examples are

So, I think we should either pick one of these as the best example and make it a shiny canonical question, or I would be willing to put together a canonical cwiki question/answer if that is better.

Any thoughts, objections, and/or helpers?

5
  • 5
    Assembling canonicals is a hard job today. May 13, 2015 at 17:02
  • 4
    Indeed @πάνταῥεῖ, but perhaps a worthwhile one . . . though perhaps not. I hate to throw up my hands and give up though.
    – dsolimano
    May 13, 2015 at 17:06
  • 2
    I've a described a step-based approach to create a canonical here
    – rene
    May 14, 2015 at 7:29
  • @rene thanks for the link, that's a useful writeup. Perhaps, some of that content should be in the canonical tag wiki, or at least it should have a link to your answer. I can work on that too if you'd like.
    – dsolimano
    May 14, 2015 at 12:38
  • I was considering that @dsolimano but I rather have some more feedback if more people agree. The current answer from Will as well as the comment from Braiam take a slightly different route. So I would hold back on declaring my post as the defacto standard.
    – rene
    May 14, 2015 at 12:46

1 Answer 1

7

The text of the exception (with all specifics removed) is

The parameterized query expects the parameter which was not supplied.

Searching for this in both Bing and Google, we get the same top result

The parameterized query expects the parameter which was not supplied

The question has two issues--it's in VB (ick), and the specified error doesn't match with the code sample. There's one bum answer, and another that goes into the injection vulnerability, which isn't optimal. The selected answer is decent, but could use improvement.

But I don't see why this shouldn't be used as the canonical. Perhaps some cleanup on the question and answer would be helpful?

The only other alternative is to create a question/answer specifically to deal with this error and all the possible different scenarios when it may crop up. That's also a possibility. Knock yourself out on that. Ask and answer at the same time, and mark the answer as community wiki. Put a note at the bottom or in a comment to suggest that you're trying to create a canonical question for the error, and ask for help developing it.

2
  • 6
    Sometimes, the only option is to ask a selfanswered question...
    – Braiam
    May 13, 2015 at 18:40
  • I like what I see. It might be as simple as a minor hijacking of the question to add a C# equivalent to the VB. I think that's acceptable, as it doesn't change what OP wrote, really . . . a bit borderline perhaps.
    – dsolimano
    May 13, 2015 at 20:47

You must log in to answer this question.

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