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. General Programming
  3. LINQ
  4. Executing sql stored procedure and storing result set in dataset

Executing sql stored procedure and storing result set in dataset

Scheduled Pinned Locked Moved LINQ
databasecsharplinqhelp
11 Posts 3 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.
  • P Offline
    P Offline
    praveenkumar palla
    wrote on last edited by
    #1

    Hi all, I need help to execute sql stored procedure using linq to sql and result set should be stored in dataset. Thanks in advance. Praveen Kumar Palla

    S L 3 Replies Last reply
    0
    • P praveenkumar palla

      Hi all, I need help to execute sql stored procedure using linq to sql and result set should be stored in dataset. Thanks in advance. Praveen Kumar Palla

      S Offline
      S Offline
      Sk93
      wrote on last edited by
      #2

      Why would it need to be in a dataset? The idea of linq to sql is to give you strongly typed objects from SQL. Putting this back into a DataSet will defeat the purpose of using Linq to SQL in the first place.. no? perhaps you want to use Ling to Dataset instead? http://msdn.microsoft.com/en-us/vbasic/bb688086.aspx[^]

      modified on Wednesday, June 24, 2009 7:05 AM

      P 1 Reply Last reply
      0
      • S Sk93

        Why would it need to be in a dataset? The idea of linq to sql is to give you strongly typed objects from SQL. Putting this back into a DataSet will defeat the purpose of using Linq to SQL in the first place.. no? perhaps you want to use Ling to Dataset instead? http://msdn.microsoft.com/en-us/vbasic/bb688086.aspx[^]

        modified on Wednesday, June 24, 2009 7:05 AM

        P Offline
        P Offline
        praveenkumar palla
        wrote on last edited by
        #3

        Thanks for the reply I need the result set should be in dataset since in my requirement there should be parent-child relation in grid for that i need to create datarelation between the different datatables in dataset and then assign the datasource to parent and child using datarelation. Please help me on this...

        S 1 Reply Last reply
        0
        • P praveenkumar palla

          Thanks for the reply I need the result set should be in dataset since in my requirement there should be parent-child relation in grid for that i need to create datarelation between the different datatables in dataset and then assign the datasource to parent and child using datarelation. Please help me on this...

          S Offline
          S Offline
          Sk93
          wrote on last edited by
          #4

          Using the "Linq to SQL classes" (dbml) designer in visual studio, you can set an association between the tables, thus setting a parent-child relationship...

          P 1 Reply Last reply
          0
          • P praveenkumar palla

            Hi all, I need help to execute sql stored procedure using linq to sql and result set should be stored in dataset. Thanks in advance. Praveen Kumar Palla

            L Offline
            L Offline
            lingareddy
            wrote on last edited by
            #5

            Good question but no result,iam also in same line

            1 Reply Last reply
            0
            • P praveenkumar palla

              Hi all, I need help to execute sql stored procedure using linq to sql and result set should be stored in dataset. Thanks in advance. Praveen Kumar Palla

              L Offline
              L Offline
              lingareddy
              wrote on last edited by
              #6

              Iam also same problem please give me a solution

              1 Reply Last reply
              0
              • S Sk93

                Using the "Linq to SQL classes" (dbml) designer in visual studio, you can set an association between the tables, thus setting a parent-child relationship...

                P Offline
                P Offline
                praveenkumar palla
                wrote on last edited by
                #7

                Hi, My stored procedure returns result set not from single table, there is some business logic in the stored procedure based on that getting the values required and inserting into temporary table created in the stored procedure finally stored procedure will return the result set from the temporary table. In the same way there are similar stored procedures and each will return the result set and there will be a relation in the result sets. Normarally we are executing the stored procedure and getting the result set(s) into the same dataset with different datatables in that and creating datarelations based on the on common value and then binding the dataset to xceed grid (third party control) as partent child but inorder to accomplish this using linq i need to execute the stored procedure and result set should be stored in dataset. Please help me on this...Thanks in advance.

                S 1 Reply Last reply
                0
                • P praveenkumar palla

                  Hi, My stored procedure returns result set not from single table, there is some business logic in the stored procedure based on that getting the values required and inserting into temporary table created in the stored procedure finally stored procedure will return the result set from the temporary table. In the same way there are similar stored procedures and each will return the result set and there will be a relation in the result sets. Normarally we are executing the stored procedure and getting the result set(s) into the same dataset with different datatables in that and creating datarelations based on the on common value and then binding the dataset to xceed grid (third party control) as partent child but inorder to accomplish this using linq i need to execute the stored procedure and result set should be stored in dataset. Please help me on this...Thanks in advance.

                  S Offline
                  S Offline
                  Sk93
                  wrote on last edited by
                  #8

                  Hi, Are you saying that the stored procedure could return different column names each time it's run? If so, I don't think it'd be possible to achieve what you want to do... If not, then my previous reply should still work, as the stored proceure will be returning the same columns each time it runs, regardless of how it builds up it's data internally. Cheers, Sk93

                  P 1 Reply Last reply
                  0
                  • S Sk93

                    Hi, Are you saying that the stored procedure could return different column names each time it's run? If so, I don't think it'd be possible to achieve what you want to do... If not, then my previous reply should still work, as the stored proceure will be returning the same columns each time it runs, regardless of how it builds up it's data internally. Cheers, Sk93

                    P Offline
                    P Offline
                    praveenkumar palla
                    wrote on last edited by
                    #9

                    Hi, My stored procedure will return same columns every time. As of now i am using the following code to bind the data to grid as partent child. Can you suggest me what to do inorder to get the same results without dataset using linq. frmGTGReport_XdgvGTGReport.DataRows.Clear() frmGTGReport_XdgvGTGReport.DetailGridTemplates.Clear() frmGTGReport_XdgvGTGReport.Columns.Clear() frmGTGReport_XdgvGTGReport.GroupTemplates.Clear() frmGTGReport_XdgvGTGReport.BeginInit() frmGTGReport_XdgvGTGReport.SingleClickEdit = True frmGTGReport_XdgvGTGReport.FixedColumnSplitter.Visible = False frmGTGReport_XdgvGTGReport.DataRowTemplate.CanBeSelected = False frmGTGReport_XdgvGTGReport.DataRowTemplate.FitHeightToEditors = True frmGTGReport_XdgvGTGReport.SynchronizeDetailGrids = True ''binding selected protocol and institution to UI as parent frmGTGReport_XdgvGTGReport.SetDataBinding(dsTemp, "Protocol") ''creating data relation for selected protocol and IRB Dim data_relation_ProtocolIRB As New DataRelation("Protocol_IRB", dsTemp.Tables("Protocol").Columns("Protocol"), dsTemp.Tables("IRBRegNo").Columns("Protocol")) dsTemp.Relations.Add(data_relation_ProtocolIRB) Dim detailGridTemplate_ProtocolIRB As New DetailGrid() detailGridTemplate_ProtocolIRB.SetDataBinding(dsTemp, "Protocol.Protocol_IRB") detailGridTemplate_ProtocolIRB.HeaderRows.Add(New ColumnManagerRow()) frmGTGReport_XdgvGTGReport.DetailGridTemplates.Add(detailGridTemplate_ProtocolIRB) Dim data_relation_IRBVersion As New DataRelation("IRB_Version", dsTemp.Tables("IRBRegNo").Columns("IRB Registration Number"), dsTemp.Tables("Versions").Columns("IRB Registration Number")) dsTemp.Relations.Add(data_relation_IRBVersion) Dim detailGridTemplate_IRBVersion As New DetailGrid() detailGridTemplate_IRBVersion.SetDataBinding(dsTemp, "Protocol.Protocol_IRB.IRB_Version") detailGridTemplate_IRBVersion.HeaderRows.Add(New ColumnManagerRow()) detailGridTemplate_IRBVersion.Collapsed = False detailGridTemplate_ProtocolIRB.DetailGridTemplates.Add(detailGridTemplate_IRBVersion) frmGTGReport_XdgvGTGReport.EndInit()

                    S 1 Reply Last reply
                    0
                    • P praveenkumar palla

                      Hi, My stored procedure will return same columns every time. As of now i am using the following code to bind the data to grid as partent child. Can you suggest me what to do inorder to get the same results without dataset using linq. frmGTGReport_XdgvGTGReport.DataRows.Clear() frmGTGReport_XdgvGTGReport.DetailGridTemplates.Clear() frmGTGReport_XdgvGTGReport.Columns.Clear() frmGTGReport_XdgvGTGReport.GroupTemplates.Clear() frmGTGReport_XdgvGTGReport.BeginInit() frmGTGReport_XdgvGTGReport.SingleClickEdit = True frmGTGReport_XdgvGTGReport.FixedColumnSplitter.Visible = False frmGTGReport_XdgvGTGReport.DataRowTemplate.CanBeSelected = False frmGTGReport_XdgvGTGReport.DataRowTemplate.FitHeightToEditors = True frmGTGReport_XdgvGTGReport.SynchronizeDetailGrids = True ''binding selected protocol and institution to UI as parent frmGTGReport_XdgvGTGReport.SetDataBinding(dsTemp, "Protocol") ''creating data relation for selected protocol and IRB Dim data_relation_ProtocolIRB As New DataRelation("Protocol_IRB", dsTemp.Tables("Protocol").Columns("Protocol"), dsTemp.Tables("IRBRegNo").Columns("Protocol")) dsTemp.Relations.Add(data_relation_ProtocolIRB) Dim detailGridTemplate_ProtocolIRB As New DetailGrid() detailGridTemplate_ProtocolIRB.SetDataBinding(dsTemp, "Protocol.Protocol_IRB") detailGridTemplate_ProtocolIRB.HeaderRows.Add(New ColumnManagerRow()) frmGTGReport_XdgvGTGReport.DetailGridTemplates.Add(detailGridTemplate_ProtocolIRB) Dim data_relation_IRBVersion As New DataRelation("IRB_Version", dsTemp.Tables("IRBRegNo").Columns("IRB Registration Number"), dsTemp.Tables("Versions").Columns("IRB Registration Number")) dsTemp.Relations.Add(data_relation_IRBVersion) Dim detailGridTemplate_IRBVersion As New DetailGrid() detailGridTemplate_IRBVersion.SetDataBinding(dsTemp, "Protocol.Protocol_IRB.IRB_Version") detailGridTemplate_IRBVersion.HeaderRows.Add(New ColumnManagerRow()) detailGridTemplate_IRBVersion.Collapsed = False detailGridTemplate_ProtocolIRB.DetailGridTemplates.Add(detailGridTemplate_IRBVersion) frmGTGReport_XdgvGTGReport.EndInit()

                      S Offline
                      S Offline
                      Sk93
                      wrote on last edited by
                      #10

                      Yes. DBML will do this for you....... http://msdn.microsoft.com/en-us/library/bb425822.aspx#linqtosql_topic5[^]

                      P 1 Reply Last reply
                      0
                      • S Sk93

                        Yes. DBML will do this for you....... http://msdn.microsoft.com/en-us/library/bb425822.aspx#linqtosql_topic5[^]

                        P Offline
                        P Offline
                        praveenkumar palla
                        wrote on last edited by
                        #11

                        Thanks i will go through and try to solve my problem...

                        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