0

I'm tying to accomplish a very basic result which is to count the number of rows in a stored procedure using WebMatrix.Data. Since I'm new to creating stored procedures and using WebMatrix.Data I would appreciate it if someone could lead me to the best practice path.

Here is what I've done so far:

CREATE PROCEDURE [dbo].[SD_photoCount]
@IDuser nvarchar (150)
AS SET NOCOUNT OFF;

SELECT Count(photos.IDphoto) AS photoCount FROM photos WHERE IDuser = @IDuser

[WebMethod]
public static string photoCount(string IDuserInput)
{   
    var photoCount_query = db.Query("Exec dbo.SD_photoCount @0", IDuserInput);
    var photoCountResult = photoCount_query.photoCount;//ERROR 
    return photoCountResult.ToString();        
}

The error I'm getting is the following:

Error 4 'System.Collections.Generic.IEnumerable' does not contain a definition for 'photoCount' and no extension method 'photoCount' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be found (are you missing a using directive or an assembly reference?)

Gloria
  • 1,305
  • 5
  • 22
  • 57
  • similar: http://stackoverflow.com/questions/10645730/return-an-output-parameter-from-sql-server-via-a-stored-procedure-and-c-sharp – Tanner Mar 06 '15 at 15:31
  • and this: http://stackoverflow.com/questions/10905782/using-stored-procedure-output-parameters-in-c-sharp – Tanner Mar 06 '15 at 15:32

0 Answers0