read stored procedure results into datagrids

Posted on 2005-04-07
Last Modified: 2010-04-23
I have strored procedures that have multiple select statements. I need to be able to run the store procedure and take the result set and add each to their own datagrid. I wont know how many select statements are in the store procedure until it is ran. What would be the best way to go about this and how?  Datareader? DataAdapter? any examples? Thanks in advance.
Question by:MadIce
    LVL 25

    Expert Comment

    Use a dataadapter and a dataset, it will read in all the tables that come from the stored procedure automatically

    LVL 25

    Accepted Solution

    So something like

            Dim SCM As New SqlClient.SqlCommand
            SCM.CommandType = CommandType.StoredProcedure
            SCM.CommandText = "PROJandPERSONS"
            SCM.Connection = SqlConnection1

            Dim da As New SqlClient.SqlDataAdapter(SCM)

            datagrid1.datasource = ds.Tables(0)
            datagrid2.datasource = ds.Tables(1)

    Author Comment

    Sorry it took so long to respond...My server went down and had to fix it before I could try this out. This Should workout. Thanks alot

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now