none
Methods returning datasets RRS feed

  • Question

  •  

    I have a few methods (stored procedures) in my LINQ to SQL class, some of which are supposed to return datasets. However when my stored procedure performs an action first, the return type on the method gets set to (none) instead of (Auto-generated Type) and therefore doesn't return the dataset.

     

    For example

     

    SELECT

           Column1,

           Column2

    FROM

           MyTable

     

    Will return the dataset whereas

     

    UPDATE

           MyTable

    SET

           ColumnX = Null

     

    SELECT

           Column1,

           Column2

    FROM

           MyTable

     

    won't

     

    Can someone explain why and tell me how to get the second example to still return the dataset?

    Thanks in advance.

    Rob

     

    Tuesday, May 27, 2008 2:30 PM

Answers

  • I have tried to reproduce this without success, in both cases my designer indicates the result set will be (Auto-generated Type).

     

    Perhaps you can send a CREATE PROCEDURE script and table definition that causes the exact error?

     

    The only thing I can think of that might otherwise cause the result to think it's integer would perhaps be the count from the first statement.  SET NOCOUNT ON in front of the update and SET NOCOUNT OFF before the SELECT would eliminate that possibility.

     

    [)amien

     

    Wednesday, May 28, 2008 11:30 PM
    Moderator

All replies

  • I have tried to reproduce this without success, in both cases my designer indicates the result set will be (Auto-generated Type).

     

    Perhaps you can send a CREATE PROCEDURE script and table definition that causes the exact error?

     

    The only thing I can think of that might otherwise cause the result to think it's integer would perhaps be the count from the first statement.  SET NOCOUNT ON in front of the update and SET NOCOUNT OFF before the SELECT would eliminate that possibility.

     

    [)amien

     

    Wednesday, May 28, 2008 11:30 PM
    Moderator
  • Damien,

    Thanks for your reply.

     

    One of my SPs had RETURN at the end so I took that out which solved it (obviously) but the other SP didn't have anything like that but i put SET NOCOUNT OFF before my last query and it solved the problem.

     

    Thanks again.

     

    Rob

     

    Thursday, May 29, 2008 9:19 AM