Monday, March 12, 2012

How to return a Table to VS using Stored Procedure

i have a Stored Procedure like below but it can't seem to return any table to Visual Studio

Code Snippet

ALTER PROCEDURE dbo.SelectHWCategoryBased

(
@.title varchar /* Like Processor/RAM */
)

AS

SELECT Hardwares.HWID, Hardwares.Title
FROM Hardwares INNER JOIN
Category ON Hardwares.CategoryID = Category.CategoryID
WHERE (Category.Type LIKE '%Hardware%') AND (Category.Title = @.Title)


There is no issue on your SP.

You have to use the SQLDataAdapater to fill the dataset. Use the current command object as SelectCommand of the Adapter & call the Fill() method.. Check with ADO.NET forum

|||

@.title varchar /* Like Processor/RAM */

The default size for an incoming varchar parameter is one character. If your incoming parameter value is longer than one character, it is being truncated, and the WHERE clause is looking for a Category.Title that matches the single character.

Probably won't find one.

Change the parameter to varchar(n) -n being sized appropriate to your Title field.

|||Thanks, that works, missed out that.

No comments:

Post a Comment