Tuesday, March 27, 2012

Filling a dataset created from stored procedure

How Do I fill as dateset that i created from a stored procedure in SQL SERVER?
I dragged an stored procedure onto the dataset template from the server explorer.
Do I use the exact same sql statement as in the stored procedure, or can I say something like "SELECT * FROM myStoredProcedure", but that is not working?

Thanks in advanceIf the stored procedure outputs a result set (or more than one), you can set the CommandText of your SqlCommand object to the name of the stored procedure and set the CommandType of your SqlCommand object to CommandType.StoredProcedure.

If your stored procedure does not output a result set, you need to issue the same select statement you have in the stored procedure, but without the variable or temporary table that is accepting the results.

If your stored procedure is returning a table variable, you need to put "select * from @.tablevariablename" at the end of the stored procedure, I think, because I don't think the ASP.NET API will accept a table variable as a stored procedure return value. I could be wrong about that, though.

No comments:

Post a Comment