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

  • SEARCH
  • Home
  • 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 9094233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:18:13+00:00 2026-06-16T23:18:13+00:00

I’m sure something like this has been asked before, but I can’t seem to

  • 0

I’m sure something like this has been asked before, but I can’t seem to find exactly what I need. Say I added a DataSet component to my VS 2010 .NET 3.5 project – it’s executing and filling up alright and is very easy to use.
But what if i wanted to make small modifications to its query at runtime (basing on various user input)?

I know i could do this with Parameters, but what if the modifications to the query have more structural character, – like omitting parameters etc.?

In the generated code i see that it exposes CommandCollection property, but it’s protected, therefore I can’t use it from outside of the dataset – unless 🙂 i make a dummy class that inherits from the generated adapter object and publicly exposes CommandCollection property by force (that’s just what I did) – but isn’t it a bit awkward?

Do you know of a better technique?

  • 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-06-16T23:18:15+00:00Added an answer on June 16, 2026 at 11:18 pm

    so since nobody answered, I post the workaround I used here (inherited class). Foreword: when you drag a DataSet class from VS 2010 toolbox to your Form (e.g. MainForm) in Design view, three things are generated :

    • a DataSet (contains table & data instances)
    • a DataAdapter (describes how to fill the above dataset)
    • a BindingSource (binds the above DataSet to controls on Form)

    The definition of the above generated classes, along with the required queries etc. is ultimately stored in an XSD file, and during each build the code for these classes is generated from the XSD.

      // MyTableAdapter is a VS2010 AUTOGENERATED class
      // (generated during DataSet wizard)
      // thankfully, MyTableAdapter exposes protected CommandCollection attribute
      class MyAdapter : MyTableAdapter
      {
          public System.Data.OracleClient.OracleCommand[] Commands
          {
              get { return CommandCollection; }
          }
      }
    
      class MainForm : Form
      {
          private void btnQuery_Click(object sender, EventArgs e)
          {
              // create new OracleCommand to substitute the SelectCommand in autogenerated adapter
              using (OracleCommand cmd = new OracleCommand())
              {
                  MyAdapter m = new MyAdapter(); // dummy instance used just to retrieve saved query
                  if (m.Commands.Length > 0)
                  {
                       cmd.Connection = mainDbConnection;
                       cmd.CommandText = m.Commands[0].CommandText.Replace('someText', 'someOtherText'); // do whatever changes to the query
                       cmd.CommandType = CommandType.Text;
                       cmd.Parameters.Add(...); // optionally, if needed
    
                       //myTableAdapter is a Designer generated instance of MyTableAdapter
                       //but I can substitute its SelectCommand with something else
                       myTableAdapter.Adapter.SelectCommand = cmd;
                       myTableAdapter.Adapter.Fill(this.myDataSet.MyTable);
                  }
              }
          }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
This could be a duplicate question, but I have no idea what search terms
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
Does anyone know how can I replace this 2 symbol below from the string
I need to clean up various Word 'smart' characters in user input, including but

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.