Search code examples
visual-studio-2010stored-proceduresdatasetstrongly-typed-dataset

Create entire DataSet from existing stored procedure


I have stored procedures (they accept parameters) that return multiple result sets and I'd like to have this saved in a typed dataSet.

The question is: can I have Visual studio 2010 generate the typed dataset based on stored procedure? I know I can have this for a single table, but I need the whole dataSet (multiple tables, one for each result set)


Solution

  • So let's do an experiment to see if it is possible..

    I created the following stored procedure in a SQL 2008 database:

    CREATE PROCEDURE dbo.StackOverflow3668337
    AS
    BEGIN
        SET NOCOUNT ON;
    
        SELECT 'First bit';
    
        SELECT 'Second bit';
    END
    

    Then I created a new project in VS2010, and added a DataSet item to the project.

    I created a connection to the database in the Server Explorer, and dragged the 'StackOverflow3668337' item onto the DataSet designer surface. This is the result:

    TableAdapter from DataSet Designer

    So that would be just one DataTable. So unfortunately I think the answer is out of the box, "No".

    I think the main reason for this is that the TableAdapter classes that are generated are just tied to a single DataTable. You can have multiple TableAdapters for a single DataTable but they all need to return the same data. There is no capacity for a single TableAdapter to interact with additional DataTables.