954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Accessing "mid-table" from database

Hello.

I have two tables in a database - Clubs and Players. Each Club consists of 25 players. So a virtual table ClubsPlayers is created.

I would like to access this tables row or cell, but I don't know how.

As you can access real tables like this:

xDataSet.Clubs[1].IdClub;
niggz
Light Poster
26 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

You can do it by the club ID or the player ID (if it actually exists).

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

It exsists. Still not sure what you think..

niggz
Light Poster
26 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

What created the table?

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

When I included the database into my c# project, it automatically created the table in dataset. But I can't find it always, but only when clubsTableAdapter and playersTableAdapter are included on the same form. (sorry about not giving that info)

niggz
Light Poster
26 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

Ah, OK.
Now, I have to ask: Do you REALLY need to access it?

Also, if you know what name it will be when it is created, can you just create a Connection, Command, Reader, etc for it and only call it once it is created?

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

Oh shoot... Thank you! Player has the field with which it is connected with a club, so I can check the ID of it... Yea that's right!

But do you think it would be a problem to go through the whole database everytime I want to access a certain player of a certain club? (it has only 250 records)

niggz
Light Poster
26 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

Since the database is small, you can just load the entire thing into memory then search.
You can do a join on the tables and map them to a class in C# and just load it with one query.

Once it is memory, you can search it however you like without more database hits.

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: