is there a way i can get my datatable to have multiple constraints that are attached to a unique id? an example of what i'm talking about is if i have a unique machine but it's on many lines, can i show that somehow in a datatable? the reason i'm asking is that i have code that sorts the data by line number and shows the relevant machines in a combo box based on the line selection out of another combo box. i'm having to input the data into the datatable (as a starting point for the data base) and it's very tedious. i'm entering machines that have the same name in multiple rows because the line number is different. i can't figure out how i can add multliple values into my line number column so that it will sort properly when queried.
an example of what i'm asking with regard to the datatable is as follows:
slicer Line 1, Line 2, Line 4
conveyor belt Line 1, Line 6
So that when called to fill the combo box, the correct one is called.
The code i'm using to sort right now is as follows:
Private Sub linecbo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles linecbo.SelectedIndexChanged Dim cline As String Dim mycon As SqlCeConnection Dim mycmd As New SqlCeCommand Dim myDA As New SqlCeDataAdapter Dim myDS As New DataSet Dim myDT As New DataTable machinecbo.Enabled = True cline = linecbo.SelectedValue mycon = GetConnect() mycon.Open() mycmd = mycon.CreateCommand mycmd.CommandText = "SELECT Machine, LineNumber FROM machine WHERE LineNumber = '" & Trim(cline) & "' ORDER BY Machine" myDA.SelectCommand = mycmd myDA.Fill(myDS, "machine") myDT = myDS.Tables("machine") machinecbo.DataSource = myDT machinecbo.DisplayMember = "Machine" machinecbo.ValueMember = "LineNumber" machinecbo.SelectedIndex = -1 End Sub
any help with this will be greatly appreciated. i've tried multiple things and i can't seem to get it right.