I am running into a strange error when I try debugging my current
application. A form loads up with a dynamically-populated textbox full
of software titles. Upon selection of a software title and pressing 'GO'
a checkboxlist is displayed with the users who use the current software.
The checkboxlist is bound to a dataset named "DataTable" and has the
DisplayMember set to "Employee" and the DataValue set to "ID", like the
following:
----
Dim strSoftwareTitle As String = comboSoftwareTitles.Text()
Dim objConn As New OleDb.OleDbConnection
objConn.ConnectionString =
System.Configuration.ConfigurationSettings.AppSett ings("strConnection")
Dim strSQL As String = "SELECT ID, EmployeeName FROM tblSoftware WHERE "
& _
"(SoftwareTitle = '" & strSoftwareTitle & "') AND " & _
"(EmployeeName Is Not Null) ORDER BY EmployeeName ASC;"
Dim ds As New DataSet
Dim objCommand As New OleDb.OleDbCommand(strSQL, objConn)
Dim myCommand As New OleDb.OleDbDataAdapter(strSQL, objConn)
myCommand.Fill(ds, "DataTable")
Me.clBox.DataSource = ds.Tables("DataTable")
Me.clBox.MultiColumn = False
Me.clBox.DisplayMember = "EmployeeName"
Me.clBox.ValueMember = "ID"
----
When I run the application the first software title in the list happens
to be "Adobe Acrobat 6.01 Professional." When I hit 'go' I get the error
below:
----
Additional information: Cannot modify the Items collection
when the DataSource property is set.
----
The line that is highlighted in debug mode is the following:
----
Me.clBox.ValueMember = "ID"
----
If I quit and run the program again and scroll down and select "Visual
NET 2003 Enterprise" and press 'GO', the checkboxlist displays
flawlessly. What could cause my application to error upon selection of
the first selection, but not another one in the list. In the subroutine
that errors I am not modifying the Items collection. If this isn't clear
enough I can provide more information.
Any suggestions?
- Will
*** Sent via Developersdex http://www.developersdex.com ***