I am writing an app in VB2005 where you can take a "test" from different instructors. After logging in, you can choose an instructor using a combo box and then choose a test from that instructor using a second combo box. As of now, I have 3 instructors with 5 tests each. I am able to display my instructor combo box correctly, but nothing is showing up in my test combo box. I am using MS Access and my table is named tblTest, with three columns named TestID, UserID, and TableName, with TestID being the primary key. As a sidenote, when I debug the program, my iUserID variable is giving me a value of 0. I'm not sure if I'm not coding it correctly, or if it's within my SQL statement. If you need more code or information, or a suggestion of how I can do this better, please let me know. Thank you very much in advance for any help you can give me.
Code from form where check boxes are located:
CODE
dsInstructor = oInstructor.GetData(m_UserID)
dsUser = oUser.GetData
cmgrInstructor = CType(Me.BindingContext(dsInstructor.Tables(0)), CurrencyManager)
For x = 0 To dsUser.Tables(0).Rows.Count
If dsUser.Tables(0).Rows(x).Item(0) = iStudentID Then
txtWelcome.Text = dsUser.Tables(0).Rows(x).Item("FullName")
Exit For
End If
Next
cboInstructor.DataSource = dsInstructor.Tables(0)
cboInstructor.DisplayMember = "FullName"
cboInstructor.ValueMember = "UserID"
dsTest = oTest.GetData(m_Test)
cmgrTest = CType(Me.BindingContext(dsTest.Tables(0)), CurrencyManager)
cboTest.DataSource = dsTest.Tables(0)
cboTest.DisplayMember = "TestName"
cboTest.ValueMember = "TestID"
Code from class:
CODE
Private Function CreateDASelectCommand() As OleDb.OleDbCommand
Dim sSQL As String 'string with SQL
Dim cmd As New OleDb.OleDbCommand(sSQL, m_oCn) 'command object
'---------------------------------------------------------
'--- Set up the SELECT Command
'---------------------------------------------------------
sSQL = "select * from tblTest" 'SQL to use
cmd.CommandText = sSQL
cmd.CommandType = CommandType.Text 'this is SQL rather than a stored procedure
Return cmd 'return the full command
End Function
Public Function GetData(ByVal iUserID As Integer) As DataSet
Dim sSQLOrig As String = "" 'The original SQL used for all records
Try
'--- Create a new DataSet
sSQLOrig = m_oDA.SelectCommand.CommandText
m_oDA.SelectCommand.CommandText &= " where UserID = " & iUserID.ToString
m_oCn.Open()
m_oDS = New DataSet
'--- Fill the DataSet with the Customers
m_oDA.Fill(m_oDS, m_sClassName)
m_oCn.Close()
'//--- Return the DataSet
Return m_oDS
Catch ex As Exception
Throw ex
Finally
'reset SQL back to generic 'Grab Everything'
m_oDA.SelectCommand.CommandText = sSQLOrig
End Try
End Function