I'm tallying a row in my access database. My databases contain movie company,movies produced by companies and the amount of movies sold. There is more info in the database than I mentioned, but for this problem I'm only looking at two columns. The movie company and the movies produced by that company. One column is called company and the other is called Movie. I need to count every movie that was produced by the movie company. I counted six different Movie companies in the database. My goal is to simply display the movie company and the number movies it produced in a listbox.
I have two big problems. 1. My result won't display in the listbox. 2 According to the good people who looked at my code. The program is not counting anything. Here is example of what I want to display
Company #Movies
Paramount 4
20thCenturyfox 8
LucasFilm 6
etc.
What I'm thinking is created a nested foreach loop and for every movie that is produced by a certain company add it to the listbox.
private void tabP3_Click(object sender, EventArgs e)
{
foreach (DataRowView row in bindingSource1.List)
{
foreach (DataRowView row2 in bindingSource1.List)
{
if(((String)row2["Company"]).Equals(row["Movie"]))
{
int count = 0;
count++;
lbCompany.Items.Add((String.Format("{0,5}", count)));
}
}
}
}