Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6248001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:58:39+00:00 2026-05-24T12:58:39+00:00

Aim to Achieve : I want to have 3 different dataTables from 3 different

  • 0

Aim to Achieve :
I want to have 3 different dataTables from 3 different SQL queries from 3 different places into 1 single DataSet which I will have to return form my function.

I have :

Private Function getDataSet()
    Dim ad1,ad2,ad3 As Object
    ad1 = New Data.OleDb.OleDbDataAdapter(query1, conStr1)
    ad2 = New Data.SqlClient.SqlDataAdapter(query2, conStr2)
    ad3 = New Data.SqlClient.SqlDataAdapter(query3, conStr3)
    Dim dataSet As New Data.DataSet

    // I want to fill dataSet with the 3 adapters !
    // ad1.Fill(dataSet) : ad2.Fill(dataSet) : ad3.Fill(dataSet)
    // Will this work ?

    ad1.Dispose() : ad2.Dispose() : ad3.Dispose()  // What does Dispose() method do ?
    Return dataSet
End Function

Dim ds = getDataSet()
data1 = ds.Tables(0)
data2 = ds.Tables(1)
data3 = ds.Tables(2)

Please Help..

  • I want to use the best possible implementation of above task.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:58:41+00:00Added an answer on May 24, 2026 at 12:58 pm

    I would not fill the DataSet but the DataTables of the DataSet with each DataAdapter:

    Private Function getDataSet() As DataSet
        Dim ds As New Data.DataSet
        ds.Tables.Add(New DataTable("Table1"))
        ds.Tables.Add(New DataTable("Table2"))
        ds.Tables.Add(New DataTable("Table3"))
    
        Using con As New OleDb.OleDbConnection("conStr1")
            Using ad As New Data.OleDb.OleDbDataAdapter("query1", con)
                con.Open()
                ad.Fill(ds.Tables("Table1"))
            End Using
        End Using
        Using con As New OleDb.OleDbConnection("conStr2")
            Using ad As New Data.OleDb.OleDbDataAdapter("query2", con)
                con.Open()
                ad.Fill(ds.Tables("Table2"))
            End Using
        End Using
        Using con As New OleDb.OleDbConnection("conStr3")
            Using ad As New Data.OleDb.OleDbDataAdapter("query3", con)
                con.Open()
                ad.Fill(ds.Tables("Table3"))
            End Using
        End Using
    
        Return ds
    End Function
    

    Any number of DataAdapter-objects can be used with a DataSet. Each
    DataAdapter can be used to fill one or more DataTable objects and
    resolve updates back to the relevant data source. DataRelation and
    Constraint objects can be added to the DataSet locally, which enables
    you to relate data from dissimilar data sources. For example, a
    DataSet can contain data from a Microsoft SQL Server database, an IBM
    DB2 database exposed through OLE DB, and a data source that streams
    XML. One or more DataAdapter objects can handle communication to each
    data source.

    More…

    ” // What does Dispose() method do ?”

    http://msdn.microsoft.com/en-us/library/system.idisposable.dispose.aspx

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    I would prefer the using-statement(see code-sample above) because it’s simplier and also closes connection etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My ultimate aim is to have an inline div on my page which horizontally
My aim is to retrieve some data from a global array which is defined
My aim is to retrieve some data from a global array which is defined
Aim To Achieve : I want to add the prevMonth's name at the end
Aim to achieve : I want to change the source data for my pivot
Aim to achieve : I want to change the SourceData of the Pivot table.
Aim to Achieve : I want the Function to accept List(Of String), Array &
Aim to Acheive : I want to execute my application from msbuild as it
Aim to achieve : Want to dump a fetched table to a excel sheet.
Hi I have created an array from core-data using: NSArray* invoiceItem =[fetchedResultsController fetchedObjects]; which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.