Binding to a Listbox... weird errors

R

Ryan Ternier

Don't ask why it's coded this way.. the clueless developer before me
coded things upside down and insideout :\

Anyways,

We have a simple SQL Query that reads a table into a DataSet.

Here's the way the query is being built:

strSQL = "SELECT FirstName + ' ' + LastName as TextField, UserID AS
ValueField FROM tblStaff " & _
"WHERE CanBeAssigned = 1"
If Not objUtil.Session("blnSystemUser") Then
strSQL &= " AND UserName <> 'icompass' "
End If
strSQL &= " UNION " & _
"SELECT D.Name + ' - ' + S.FirstName + ' ' + S.LastName as
TextField, S.UserID AS ValueField " & _
"FROM tblStaff S, tblDepartments D " & _
"WHERE S.MainContact = 1 " & _
"AND S.DepartmentID = D.DepartmentID "
If Not objUtil.Session("blnSystemUser") Then
strSQL += " AND S.UserName <> 'icompass' "
End If
strSQL += " ORDER BY TextField "
dadSQL.SelectCommand.CommandText = strSQL
dadSQL.Fill(dstData, "tblItemStaffResponsible")


-------
'Binding
lstOwner.DataSource = objDataIn.DataSet
lstOwner.DataMember = "tblItemStaffResponsible"
lstOwner.DataTextField = "TextField"
lstOwner.DataValueField = "ValueField"
lstOwner.DataBind()



When it hits lstOwner.DataBind() It will catch an exception that tells me:

Message "Specified argument was out of the range of valid values.
Parameter name: value"


-----
The query that is ran returns these results:
------------------

TextField ValueField
Jake Sysadmone 2
Ryan Ternier 16


Any suggestions on why it's hitting the Catch?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top