Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Multiple Select Statement in stored procedure

Multiple Select Statement in stored procedure

Scheduled Pinned Locked Moved Database
databasecsharpasp-netquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    deepseeindeepsy
    wrote on last edited by
    #1

    Sir, In my ASP.NET application I have the dashboard. Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done. Thanx :)

    I M N 3 Replies Last reply
    0
    • D deepseeindeepsy

      Sir, In my ASP.NET application I have the dashboard. Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done. Thanx :)

      I Offline
      I Offline
      i j russell
      wrote on last edited by
      #2

      Try googling for "ado.net multiple result sets".

      1 Reply Last reply
      0
      • D deepseeindeepsy

        Sir, In my ASP.NET application I have the dashboard. Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done. Thanx :)

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        If you are trying to get multiple records from the same table them multiple selects are not required. If you have multiple records sets coming from different table then you will need multiple selects. WARNING multiple recordset returned from the same can destroy your system, it can be dramatically slower to get multiple recordsets.

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        • D deepseeindeepsy

          Sir, In my ASP.NET application I have the dashboard. Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done. Thanx :)

          N Offline
          N Offline
          Niladri_Biswas
          wrote on last edited by
          #4

          Hi, coming to ur question

          deepseeindeepsy wrote:

          Is it possible to fetch it?

          Ans : Yes I am giving a small example Step 1: Create the Stored Proc

          Alter Procedure GetMultipleRecords

          As

          Begin

             -- First select
          
                Select \* from test1
          
              -- Second   select
          
                Select \* from test2
          

          End

          So this will give u two record sets Step 2: Use Data Adapter & DataSet

          From Asp.net application, by using DataAdapter get the records set into the DataSet

          Step 3: Use respective datatable(s) from DataSet Get the record sets from the DataSet into DataTable(some pseudo code in c#) e.g.

           DataSet ds = getDataRecords();->You will get the records from database
          
           if(ds!=null && ds.tables.count > 0)
           {
          

          //Store the result for Select * from test1 into datatable firstDt

                DataTable firstDt = ds.tables\[0\]; 
          

          //Store the result for Select * from test2 into datatable secondDt

                DataTable secondDt = ds.tables\[1\]; 
           }
          

          Hope you get the idea. Now try by urself and I am sure you will reach the point. Have a nice day. :)

          Niladri Biswas

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups