CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Batch Operation!!!

  1. #1
    Join Date
    Apr 2004
    Posts
    123

    Batch Operation!!!

    I have 3 different select queries querying 3 different tables in my DB.I need all of them to be executed at once as a batch and retrieve the results and fill a dataset with 3 different tables representing the results of 3 different select queries.How do i do that???

    After executing the below mentioned code 'am getting only the first select queries data.

    Code:
      
      #region QUERIES
            string getCustomers     = "SELECT * FROM Customers";
            string getCategories    = "SELECT * FROM Categories";
            string getEmployees     = "SELECT * FROM Employees";
            #endregion
    
            public DataSet GetData()
            {
                DataSet data                = new DataSet("Batch Data");
                OleDbConnection connection  = new OleDbConnection(Properties.Settings.Default.nwindConnectionString);
                OleDbCommand command        = connection.CreateCommand();            
                OleDbDataAdapter adapter    = new OleDbDataAdapter();
    
                adapter.SelectCommand = new OleDbCommand(getCustomers, connection);
                adapter.SelectCommand = new OleDbCommand(getCategories, connection);
                adapter.SelectCommand = new OleDbCommand(getEmployees, connection);
               
                try
                {
                    connection.Open();
                    adapter.Fill(data);
                }
                catch (OleDbException error)
                {
                    System.Diagnostics.Debug.WriteLine(error.Message);
                }
                finally
                {
                    command.Dispose();
                    adapter.Dispose();
                    connection.Dispose();
                }
                
                return data;
            }

  2. #2
    Join Date
    Dec 2007
    Location
    South Africa
    Posts
    263

    Re: Batch Operation!!!

    hi

    Obviosly it will fill the First command object. You have to add the Datatables into the Dataset. That means you. Each Command object must have its own name and when you execute it, you must fill the Datatable and after that add the datatable into the Dataset and return a Dataset as you did

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)