Results 1 to 2 of 2

Thread: Database help

  1. #1

    Thread Starter
    Hyperactive Member jlt7's Avatar
    Join Date
    Jan 2006
    Posts
    413

    Database help

    I have a movie database program that I would like for my movies to be sorted by there genre, I can get it to work partially but it still doesn't sort all of them out correctly.
    anyway, I have 2 tables in my database the genre table witch lists the genres on the treeview like
    Action
    Adventure
    Ect...
    Ect...
    and the movies table witch has the movies names genre and so on, my problem is that in my movies table the genre is stored like so (Action§Adventure§Comedy§) and I can't figure out how to make my code read them and sort them correctly
    heres is my code that I have tried but doesn't work correctly
    also my code is in a module if that helps any
    VB Code:
    1. Case "Genre"
    2.             rsGenre.MoveFirst
    3.             Do While Not rsGenre.EOF
    4.                 nodeX2.Text = Split(nodeX2.Text, "§")
    5.                 Set nodeX2 = treView.Nodes.Add("Collection", tvwChild, rsGenre.Fields("Genre"), rsGenre.Fields("Genre"), "Closed")
    6.                 nodeX2.Tag = "G|" & rsGenre.Fields("Genre")
    7.                 rsGenre.MoveNext
    8.                Loop
    9.             rsMovies.MoveFirst
    10.             Do While Not rsMovies.EOF
    11.                 strTemp = rsMovies.Fields("Genre")
    12.                 Set nodeX = treView.Nodes.Add(strTemp, tvwChild, , rsMovies.Fields("Title"), "File")
    13.                 nodeX.Tag = "T|" & rsMovies.Fields("MovieID")
    14.                 rsMovies.MoveNext
    15.             Loop
    16.             GoTo Finished

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Database help

    I think you really need to make a change in the database design. There should be a table between the moive table and the genre table. This table would hold the primary keys from both tables. This is the normal way of setting up a many-to-many relationship in a database.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width