Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Creating a subset

Creating a subset

Scheduled Pinned Locked Moved Database
csharpdatabasejsontutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    numbrel
    wrote on last edited by
    #1

    For a Windows form using VB.NET and an Access database of community events. I have a DataAdaptor and DataSet that create a datatable with a row for each event. I also have a DataAdaptor and DataSet that create a datatable for sponsoring organizations. I would like to have a combo box to choose the organization (bound to the organization table) and then populate the event combo box with a list of events sponsored by that organization. The user would then choose the event and the rest of the form controls would fill with the information for that event. How would I create a subset of events based on the sponsoring organization? Do I create another DataAdaptor and DataSet through code to create an event table based on the organization chosen? The books I have describe how to create DataAdaptor and DataSets through code, but once created, is there a way to destroy them and create others based on choosing another sponsoring organization?

    J 1 Reply Last reply
    0
    • N numbrel

      For a Windows form using VB.NET and an Access database of community events. I have a DataAdaptor and DataSet that create a datatable with a row for each event. I also have a DataAdaptor and DataSet that create a datatable for sponsoring organizations. I would like to have a combo box to choose the organization (bound to the organization table) and then populate the event combo box with a list of events sponsored by that organization. The user would then choose the event and the rest of the form controls would fill with the information for that event. How would I create a subset of events based on the sponsoring organization? Do I create another DataAdaptor and DataSet through code to create an event table based on the organization chosen? The books I have describe how to create DataAdaptor and DataSets through code, but once created, is there a way to destroy them and create others based on choosing another sponsoring organization?

      J Offline
      J Offline
      Just Greeky Creek
      wrote on last edited by
      #2

      Do u mean that u got 2 combobox, 1st lists organisations, 2nd lists events sponsored by selected organisation in 1st ComboBox? If so; I think u have two tables, one has organisations list, others has events then assume two table is related to each other with OrganisationID. 1. Warn = use Just ONE DATASET, if not, it s painful. ============================================================================ Imports System.Data.SqlClient Public Class frmOrganisationsAndEvents Inherits System.Windows.Forms.Form ' On Form There is two ComboBox named cmbOrganisations and cmbEvents Dim cnOE As New SqlConnection("") Dim dsOE As New DataSet Dim dRowOE() As DataRow Private Sub frmOrganisationsAndEvents_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim adpOE As New SqlDataAdapter("SELECT * FROM Organisations", cnOE) adpOE.Fill(dsOE, "Organisations") adpOE.SelectCommand.CommandText = "SELECT * FROM Events" adpOE.Fill(dsOE, "Events") For i As Short = 0 To dsOE.Tables("Organisations").Rows.Count - 1 cmbOrganisations.Items.Add(dsOE.Tables("Organisations").Rows(i)("O_OrganisationName")) Next If Not cmbOrganisations.Items.Count = 0 Then cmbOrganisations.Text = "Select an Organisation" Else cmbOrganisations.Text = "No Organisation Installed" End If End Sub Private Sub cmbOrganisations_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbOrganisations.SelectedIndexChanged If Not cmbOrganisations.Items.Count = 0 And cmbOrganisations.SelectedIndex = -1 Then cmbEvents.Items.Clear() **'Events SubSet** drowOE = dsOE.Tables("Events").Select("E_OrganisationID=" & dsOE.Tables("Organisations").Rows(cmbOrganisations.SelectedIndex)("O_OrganisationID")) If Not dRowOE.Length = 0 Then For i As Short = 0 To dRowOE.GetUpperBound(0) cmbEvents.Items.Add(dRowOE(i)("E_EventAlias")) Next cmbOrganisations.Text = "Select Event Sponsored by " & dsOE.Tables("Organisations").Rows(cmbOrganisations.SelectedIndex)("O_OrganisationName") Else cmbOrganisations.Text = "No Event Installed Sponsored by " & dsOE.Tables("Organisations").Rows(cmbOrganisations.SelectedIndex)("O_OrganisationName") End If End If End Sub Priv

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups