Skip to Main Content

Oracle Developer Tools for Visual Studio

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

[RESOLVED] Populating combobox from oracle data table

user400097Aug 23 2008 — edited Aug 23 2008
Hi all,


I try to populate a combobox from oracle data table.
Here's the code that I used:


Code:
Function GetComboHeaders(ByVal ORAstrConnection As String, ByVal cmbComboBox As ComboBox, _
ByVal stComboType As String, ByVal stLanguageId As String, ByVal stFormId As String, _
ByRef stValueId As String, ByRef stValueDesc As String) As ComboBox
Dim stComboTypeWhere As String
Dim stSQL As String
Try
Dim cnnConn As New OracleClient.OracleConnection(ORAstrConnection)
cnnConn.Open()
Dim cmdComboHeaders As OracleClient.OracleCommand = New OracleClient.OracleCommand
cmdComboHeaders.Connection = cnnConn
If stValueId = "" Then
stComboTypeWhere = "object_id like '" & stComboType & "%'"
Else
stComboTypeWhere = "object_id='" & stComboType & stValueId & "'"
End If
cmdComboHeaders.CommandText = "select substr(object_id, instr(object_id, '" _
& stComboType & "')+length('" & stComboType & "')) object_id, object_name from " _
& "dictionary where language_id='" & stLanguageId & "' and form_id='" _
& stFormId & "' and " & stComboTypeWhere
cmdComboHeaders.CommandType = CommandType.Text
Dim daComboHeaders As New OracleClient.OracleDataAdapter
daComboHeaders.SelectCommand = cmdComboHeaders
Dim dtComboHeaders As New DataTable
daComboHeaders.Fill(dtComboHeaders)
cmbComboBox.ValueMember = "object_name"
cmbComboBox.DisplayMember = "object_id"
cmbComboBox.DataSource = dtComboHeaders
cnnConn.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
Return cmbComboBox
End Function


The result of this code is combo box filled with System.Data.DataRowView instead of the values from the data table. (The number of rows that apear with this message is the number of returned rows from database).


If I place the decleration of the datasource before the valuemember and displaymember like this:


Code:
cmbComboBox.DataSource = dtComboHeaders
cmbComboBox.ValueMember = "object_name"
cmbComboBox.DisplayMember = "object_id"



I get an error "could not bind the new display member. Parameter name newDisplayMember", and than I get the real values from the data table.


I looked for a solution how to do it, but yet have'nt find one.
As I understand this problem exsit when the database is Oracle and not SQL Server.


Does anyone have any idea gow to solve it?


Thanks
Ohad

Edited by: user400097 on Aug 23, 2008 11:44 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2008
Added on Aug 23 2008
1 comment
2,404 views