title: Inserting records to database from multiple checkboxes in vb.net
body: <p>I have a table like these:</p>
  
  <p>Club Table contains: ClubID(IDENTITY), Name, Address</p>
  
  <p>Genre table contains: GenreID and Genre</p>
  
  <p>ClubGenre table contains Club ID, GenreID</p>
  
  <p>Club has a one to many relationship with Genre</p>
  
  <p>I created an application that functions like a database editor. I have a group of checkbox contained in a group box labeled Genres. It contains the Genre in the Genre table. This is not databound though, I typed it manually. I'm having troubles with my Add/Save button. What I'm basically trying to do is this</p>
  
  <ul>
  <li>Click New record button</li>
  <li>textboxes and checkboxes will be enabled</li>
  <li>input data</li>
  <li>click save</li>
  <li>Insert Name and address into club table (I know how to do it up to this part)</li>
  </ul>
  
  <p>Since my ClubID is IDENTITY, it will be auto generated right. I need this ClubID to insert data into my ClubGenre table.</p>
  
  <p>Let's say checkbox 1 labeled Pop is checked . In my genre table, it contains a record namely 1 as genreID and Pop as genre</p>
  
  <p>This means my insert statement will be like: </p>
  
  <pre><code>INSERT INTO Genre VALUES(*thenewlyaddedClubID*,1)
  </code></pre>
  
  <p>Now if checkbox 1,3,5 are checked it will be like:</p>
  
  <pre><code>INSERT INTO Genre VALUES(*thenewlyaddedClubID*,1)
  INSERT INTO Genre VALUES(*thenewlyaddedClubID*,3)
  INSERT INTO Genre VALUES(*thenewlyaddedClubID*,5)
  </code></pre>
  
  <p>I've come up with a solution in retrieving the newly added CLUB ID but can't put it all together yet. I'm thinking of putting the new clubID in a hidden textbox using the statement </p>
  
  <pre><code>SELECT MAX(clubID) AS barid FROM club
  </code></pre>