TableAdapter returns "object" instead of "int?" for a "GetCount" stored procedure

Last post 01-19-2008 4:40 PM by klynn125. 2 replies.

Sort Posts:

  • Angry [:@] TableAdapter returns "object" instead of "int?" for a "GetCount" stored procedure

    04-08-2007, 4:52 PM
    • Loading...
    • anjan011
    • Joined on 02-01-2006, 7:22 AM
    • Dhaka
    • Posts 17

    I am using a table adapter to generate a typed dataset. I used the wizard to create a method named "GetAllUsersCount" in dal which calls a stored procedure which has the following code ----

    SET NOCOUNT ON

    ;

    SELECT

    COUNT(*) AS Expr1

    FROM

    tenderdigest.UserInfo

    using this code in the procedure the wizard creates a method named "GetAllUsersCount" which returns "int?" , which is i expect.

     But later , i created another procedure with code ---

    SET NOCOUNT ON

    ;

    SELECT

    COUNT(*) AS Expr1

    FROM

    tenderdigest.UserInfo where email = @email

    which the adpater generates as "GetCountByEmail" which return an "object" which is unexpected. I used same procedure to create both methods in DAL but one returns int? and one object, which is certainly not what i want.

    So, what can i do to force the TableAdaper return the value as the same datatype like int?, string, DateTime? or anything else as i want? Plz help.

  • Re: TableAdapter returns "object" instead of "int?" for a "GetCount" stored procedure

    04-09-2007, 2:48 AM
    Answer

    hi,

    Right Click the  tableadapter and select add Query from that option..

    now as u said we will get a wizard

    the first item in the wizard is to select the "Choose cammand type" here choose the apropriate one that u needed. click next

    now u get "Choose QUERY TYPE"  here choose the radio button "select which returns a single value" and Click next..

    we choose this option for taking the count ,sum etc..

    hope this will help u 

     

     

    |__Roshan__|
  • Re: TableAdapter returns "object" instead of "int?" for a "GetCount" stored procedure

    01-19-2008, 4:40 PM
    • Loading...
    • klynn125
    • Joined on 01-10-2008, 6:51 PM
    • Posts 5

    I'm having the same problem.  I have a stored proc that should return a single string, but the table adapter method's return value is an int? and I get an error message every time I try and run it.  Someone else has a similar stored proc, but the return value in the table adapter's query is an object, but I have yet to figure out how they did that.

Page 1 of 1 (3 items)