Second combo box will not display anything

Uses info from first combo box and dataset

Page 1 of 1

1 Replies - 1875 Views - Last Post: 25 February 2008 - 04:50 AM Rate Topic: -----

#1 mikjall77  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 47
  • Joined: 18-April 07

Second combo box will not display anything

Posted 25 February 2008 - 02:50 AM

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:
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:
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


Is This A Good Question/Topic? 0
  • +

Replies To: Second combo box will not display anything

#2 mikjall77  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 47
  • Joined: 18-April 07

Re: Second combo box will not display anything

Posted 25 February 2008 - 04:50 AM

Nevermind, I got it working.

This post has been edited by mikjall77: 25 February 2008 - 04:52 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1