0

I have a stored procedure which I cann from my C# code. I am passing some parameters which I put in a HashTable first. It looks like that:

paramname1 value1
paramname2 value2
paramname3 value3

Any of the values can be null. So now I am going through that hash and add the params to the adapter:

foreach (DictionaryEntry entry in myHash)
{
    adapter.SelectCommand.Parameters.AddWithValue(entry.Key.ToString(), entry.Value);
}

This works, but when I try to fill a DataSet, it fails:

DataSet reportDataSet = new DataSet();
adapter.Fill(reportDataSet);

The error message is that it complains about a missing procedure parameter. Ideas?

Thanks :-)

4

1 に答える 1

3

そのかどうかを確認しnullて設定する必要があると思いDBNull.Valueます。nullそうでない場合は、値があるためパラメータが欠落していると見なされnullます。

于 2010-07-15T09:32:04.193 に答える