'adding' to DB table

  • Thread starter Thread starter Ken Foskey
  • Start date Start date
K

Ken Foskey

I am brand new to coding C# and Visual Studio.

I have worked out how to configure the ComboBox creating my own object
however it leave me with a lot of management updating as the table
changes.

I would like to add to the table, so if you think sport, a game is
played in a stadium that is located in a country.

game has one venue has one country

I would like to display in the combo box the:
"game description - venue (Country)"
I have done this with a loop and building an but then I loose the
connection between the game datasource when I change the drop box. I
would like to add this description to the table somehow.

I would also like to add the country to the game so that it is all on one
datasource to make the whole linking process easier. Venues are
obviously pretty static.

I have tried to find something with google but cannot find the wood for
the trees.

Can someone please help / point me to a description.

Ta
Ken
 
I really don't understand the description of your problem. Could you post
your code so we can see what you're doing?
 
I don't understand how to get to the code. When I select the 'game'
datasource, I want ComboSelect comes up as a field I can use to populate
the ComboBox. ComboSelect looks something like this:

String ComboSelect
{
get {
read venue using this.venuecode, get venuedesc and countrycode;
read country using countrycode returning countrydesc;
return formatted( "{0} ({1}) - {2}", this.description,
venudesc, countrydesc);
}
}

I have the actual pseudo code working to do the above, I want to add the
method to the actual game object.

datasource game is derived from an access table automatically by adding a
datasource. How do I extend 'game' to add the extra fields. I can then
use the new improved description in my combo box automatically.

Ta
Ken
 
This still doesn't tell us anything about your problem. If you don't know
how to even see your own code, how can we help you with it?
 
If you're using .NET 2.0 you're probably not showing all the files in the
solution. The designer generated code gets placed into a seperate file now
using the partial class functionality that was introduced with 2.0. Since
you don't know where the code is at, I'm guessing you're using the designer
to hook your control to your data, in which case to see it you're going to
need to do the following:

In solution explorer, click the project you were talking about. Next, you
should see 4 buttons being displayed at the top of the solution explorer,
one of them will be named "Show All Files". Simply click it to view the rest
of the files associated with the project. You should see +s next to your
Form names. If you expand the form where your combobox is at, you'll see a
<form>.designer.cs file in there. That's where the code will be at that is
being used to populate the data.

Also, about the designer files - they get generated quite frequently so it's
best to leave the code in there alone.

"I have worked out how to configure the ComboBox creating my own object
however it leave me with a lot of management updating as the table
changes."

Using an ORM tool such as LINQ to SQL might help alleviate those headaches
for you - however depending on your skill level you might spend more time
learning it and forget what you were working on to begin with. :)
 
This still doesn't tell us anything about your problem. If you don't
know how to even see your own code, how can we help you with it?


Here is the code. Not sure how it will help you:

I would like to NOT create a separate class but add a column to the match
table creating calculated column then I can simply use the values in a
combobox rather than building a separate set of objects manually.



/// <summary>
/// Display class for the Match selection dialogue
/// </summary>
internal class MatchSelect
{
private int matchId;
private int country;
/// <summary>
/// Numeric Match ID
/// </summary>
public int Id
{
get { return this.matchId; }
}
/// <summary>
/// Numeric Country code
/// </summary>
public int Country
{
get { return this.country; }
}
private StringBuilder display;
internal MatchSelect(CaptureMatch form, int id, String matchDesc,
int venue, int competition )
{
String ven;
matchId = id;
cricdet2000DataSet.tblVenueRow row =
form.cricdet2000DataSet.tblVenue.FindByID(venue);
if (row == null)
{
country = 0;
ven = "Unknown";
}
else
{
country = row.Country;
ven = row.Title;
}
cricdet2000DataSet.tblCompetitionRow row2 =
form.cricdet2000DataSet.tblCompetition.FindByID(competition);
String venueComp;
if (row2 == null)
{
venueComp = "Unknown comp";
}
else
{
venueComp = row2.Title;
}
display = new StringBuilder("");
display.AppendFormat("{0} ({1}) * {2}", matchDesc, ven,
venueComp);
}

/// <summary>
/// Match description as 'match (venue) - competition' for combo
box
/// </summary>
/// <returns> String match (venue) - competition</returns>
public override String ToString()
{
return display.ToString();
}
}
 
Using an ORM tool such as LINQ to SQL might help alleviate those
headaches for you - however depending on your skill level you might
spend more time learning it and forget what you were working on to begin
with. :)


I have to say I am already doing that.

I don't want to hack it so that it works, that would leave an
unsupportable mess.

Ta
Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top