Problems with movie database, Cannot add stars to movies and movies to star

justlearning

Member
Joined
Dec 11, 2008
Messages
16
Programming Experience
Beginner
I have been doing this project for my final (due tomorrow) for a week. I finally got my data to save and everything working right except for one problem. On my add/edit form I can add a whole new movie, which includes the movie id, movie genre, movie title, and all the actors/actresses in the movie. What I cannot add is movies to actors/actresses. For instance: Morgan Freeman was in both Along Came a Spider and Kiss the Girls. I cannot figure out how to get this to work. So what I tried was to change up the parent form. So now I have two forms, one to add the movie, title and actor/actress(s) and one to add the movies to the actor/actress. New problem, now when I display my titles I have two of the same title with different actors/actresses. For instance:

Along Came a Spider
Morgan Freeman

Along Came a Spider
Monica Potter

Kiss the Girls
Morgan Freeman

Kiss the Girls
Ashley Judd

What I am going for here is:

Along Came A Spider
Morgan Freeman
Monica Potter

Kiss the Girls
Morgan Freeman
Ashley Judd

I am not sure my code will do you any good at this point but I will give you code from both the add/edit forms and a screenshot of my dataset.xsd with the relationships identified. Please Please Please help me...

Thank you so much

Add movie title to individual stars
VB.NET:
Public Class AddStars
    Private Sub AddStars_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'SqlmovieprojectdbDataSet.Title' table. You can move, or remove it, as needed.
        Me.TitleTableAdapter.Filltitleabc(Me.SqlmovieprojectdbDataSet.Title)
        'TODO: This line of code loads data into the 'SqlmovieprojectdbDataSet.Starring' table. You can move, or remove it, as needed.
        Me.StarringTableAdapter.Fillstarabc(Me.SqlmovieprojectdbDataSet.Starring)


    End Sub

    Private Sub StarringBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StarringBindingNavigatorSaveItem.Click
       'validate all     
        Me.Validate()
        
      'update star table
      Me.StarringBindingSource.EndEdit()
      Me.StarringTableAdapter.Update (Me.SqlmovieprojectdbDataSet.Starring)

    'Update title table  
      Me.TitleBindingSource.EndEdit()
      Me.TitleTableAdapter.Update(Me.SqlmovieprojectdbDataSet.Title)

    End Sub
End Class

Edit/Add title, movie information, star for individual movie

VB.NET:
Public Class EditMovieForm
    Private Sub EditMovieForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'SqlmovieprojectdbDataSet.Starring' table. You can move, or remove it, as needed.
        Me.StarringTableAdapter.Fillstarabc(Me.SqlmovieprojectdbDataSet.Starring)
        'TODO: This line of code loads data into the 'SqlmovieprojectdbDataSet.Title' table. You can move, or remove it, as needed.
        Me.TitleTableAdapter.Filltitleabc(Me.SqlmovieprojectdbDataSet.Title)
        'TODO: This line of code loads data into the 'SqlmovieprojectdbDataSet.Movie' table. You can move, or remove it, as needed.
        Me.MovieTableAdapter.Fill(Me.SqlmovieprojectdbDataSet.Movie)

    End Sub

    Private Sub MovieBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MovieBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.MovieBindingSource.EndEdit()
        Me.MovieTableAdapter.Update(Me.SqlmovieprojectdbDataSet.Movie)

        Me.TitleBindingSource.EndEdit()
        Me.TitleTableAdapter.Update(Me.SqlmovieprojectdbDataSet.Title)

        Me.StarringBindingSource.EndEdit()
        Me.StarringTableAdapter.Update(Me.SqlmovieprojectdbDataSet.Starring)
    End Sub
End Class

Thank you for any help you can give me.
My screen shot is too big to send to you apparently.
 

Attachments

  • finalprojectscreenshot.jpg
    finalprojectscreenshot.jpg
    126.9 KB · Views: 28
You have been given this as an assignment because it is a classic Many-Many relationship

A movie has many actors
Many Actors have a movie


Thus you should have tables:

Movies
------
MovieID
MovieName

Actor
-----
ActorID
ActorName

MovieCast
----------
MovieID
ActorID
CharacterName


For example

Then you have your dataset like:


[Movies] 1-----M [MovieCast] M-----1 [Actors]

The action of assigning a movie to an actor or an actor to a movie comes from populating the MovieCast table and both operations are performed in the same way
You could have a datagrid where two columns are DataGridViewComboBox types
The DataSource for the comboboxes would be Movies/Actors tables but the combo itself is bound to the MovieCast table
i.e. the dropdown shows rows from the Movies table but changing the value causes the MoviesCast row to be edited.
In the designer you would have:
DataSource = Movies
DisplayMember = MovieName
ValueMember = MovieID
DataPropertyName = MovieCast.MovieID

Now the datagridviewcombo is capable of editing the MovieCast table using the data found in Movies and showing the user a nice text rather than an ID number

The same is true of a normal combo if youre not using a datagridview.. just remember that the normal combo has to have:

DataSource = Movies
DisplayMember = MovieName
ValueMember = MovieID
(DataBindings)SelectedValue bind to MovieCast.MovieID
REMOVE ANY OTHER BINDINGS. By default the designer binds the .Text property. Remove that binding


For more info, search for all topic titles called cjard movies and watch the datagridviewcombobox one
 
Back
Top