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 880515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:06:40+00:00 2026-05-15T12:06:40+00:00

I have a typed dataset in my project. I would like to populate a

  • 0

I have a typed dataset in my project. I would like to populate a datatable with only one row instead of all rows. The selected row must be based on the primary key column. I know I could modify the designer code to achive this functionality however if I change the code in the designer I risk that this code will be deleted when I update my datased via designer in the future.

So I wanted to alter the SelectCommand not in the designer but just before firing up MyTypedTableAdapter.Fill method. The strange thing is that the designer does not create a SelectCommand! It creates all other commands but not this one. If it would create SelectCommand I could alter it in this way:

this.operatorzyTableAdapter.Adapter.SelectCommand.CommandText += " WHERE MyColumn = 1";

It is far from perfection but atleast I would not have to modify the designer’s work. unfortunately as I said earlier the SelectCommand is not created. Instead designer creates something like this:

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
private void InitCommandCollection() {
    this._commandCollection = new global::System.Data.SqlClient.SqlCommand[1];
    this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand();
    this._commandCollection[0].Connection = this.Connection;
    this._commandCollection[0].CommandText = "SELECT Ope_OpeID, Ope_Kod, Ope_Haslo, Ope_Imie, Ope_Nazwisko FROM dbo.Operatorzy";
    this._commandCollection[0].CommandType = global::System.Data.CommandType.Text;
}

It doesn’t make sense in my opinion. Why to create UpdateCommand, InsertCommand and DeleteCommand but do not create SelectCommand? I could bear with this but this._commandCollection is private so I cannot acces it outside of the class code.

I don’t know how to get into this collection without changing the designer’s code. The idea which I have is to expose the collection via partial class definition. However I want to introduce many typed datasets and I really don’t want to create partial class definition for each of them.

Please note that I am using .NET 3.5.

I’ve found this article about accessing private properties but it concerns .NET 4.0

Thanks for your time.

  • 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-15T12:06:41+00:00Added an answer on May 15, 2026 at 12:06 pm

    In the Dataset designer, first configure a Table/Adapter pair with the basic (all rows) query. Make sure it works and updates/deletes etc.

    Then right-click, “Add Query” and change the SQL text to include a “WHERE MyId = @Id”. Make sure you keep the same columns. Select Next and call the generated method “FillById()”.

    Ad of course, use FillById(id) instead of Fill() at the right places.

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

Sidebar

Related Questions

I have a strongly typed DataTable created with the VS2005/VS2008 DataSet designer. The table
I have a datatable in a typed dataset with a date column When I
Greetings, I'm working in windows application using C#. I have typed-dataset called packetsDBDataSet and
I have a (disconnected) typed Dataset in an XML, which I query in LINQ:
I have a simple select from a typed dataset: var productlist = from prds
i have an strongly typed object that represents all of the textbox properties of
I have a project which uses strongly typed datasets. Let's assume I want to
I'm working on a project where we have a pre-existing DataSet . We don't
So I have a typed dataset that I have created records for from another
I have a typed DataSet with two TableAdapters (1 to many relationship) that was

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.