DataAdapter.Fill question

  • Thread starter Thread starter Patrick Kristiansen
  • Start date Start date
P

Patrick Kristiansen

Hi!

I'm using a SqlDataAdapter to fill a DataTable, but I seem to have
problem when the SelectCommand returns no rows. The SelectCommand is
actually a stored procedure which has one parameter and essentially is
just a SELECT-query. The error it gives me, is this when there are no
records to return

<error>
Procedure 'HentKurv' expects parameter '@Ejer', which was not
supplied.
</error>

(Nevermind the names).

Is this an expected behavioiur of the SqlDataApapter.Fill method, or
should I look for an answer elsewhere in my code?

Regards,
Patrick
 
Patrick it sounds to me like your stored procedure has a parameter called @Ejer that you have to pass to it for it to properly return the result set back to you. When building your command object you need to add this parameter to the command objects parameter collection

Keenan
 
One more thing I just thought of can you reproduce the error in Query
Anaylser when returning no rows?

Keenan
 
Hello!

I already added the paramter, and I doublechecked the name and type of
it. I tried to reproduce the problem by writing a small program that did
the same thing... I couldn't reproduce the problem.

About the query analyzer: I don't have it... does it come with MSDE?

Regards,
Patrick
 
Pay the $39.95 and get SQL Server Developer Edition. It has all the tools.
Let's see the SP code and the code you're using to call it--not just the
Fill. How are you creating the DataAdapter?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Thanks for the help, but I think I solved it now... by accident the
parameter's value was set to null because I forgot to do some checking
on some values. Apparantly it will give an error setting the
SqlParameter.Value property to null - and that might be obvious, but I
didn't see it at first.

Thanks again,
Patrick
 
Back
Top