combo box (display member) error

  • Thread starter Thread starter Harshil
  • Start date Start date
H

Harshil

I am developing an application in vb.net and oracle as my database. my
goal is to display the county names (display member) to the user while
store county id (value member) in the combo box. when I run my code I
get county id displayed in the combo box rather than the county names.

When I tried debugging my code I found out the display member and the
value member get assigned the same value i.e ID.

What could possibly be wrong??


code
====================================


Dim Connect As OleDbConnection
Dim DA_County As OleDbDataAdapter
Dim DS_County As New DataSet()
Dim DT_County As New DataTable()
Dim gConnectString as string

gConnectString = "Provider=MSDAORA;" & _
"Data Source=dd;" & _
"User ID=dd; " & _
"Password=dd; "

Connect = New OleDbConnection(gConnectString)
Connect.Open()

DA_County = New OleDbDataAdapter("Select CountyName Name, CountyNo ID
from ipt.tblcounty order by CountyName", Connect)
DA_County.Fill(DS_County)
DT_County = DS_County.Tables(0)

cboCty.ValueMember = "ID"
cboCty.DataSource = DT_County
cboCty.DisplayMember = "Name"

Connect.Close()
Connect = Nothing
 
I am developing an application in vb.net and oracle as my database. my
goal is to display the county names (display member) to the user while
store county id (value member) in the combo box. when I run my code I
get county id displayed in the combo box rather than the county names.

When I tried debugging my code I found out the display member and the
value member get assigned the same value i.e ID.

What could possibly be wrong??


code
====================================


Dim Connect As OleDbConnection
Dim DA_County As OleDbDataAdapter
Dim DS_County As New DataSet()
Dim DT_County As New DataTable()
Dim gConnectString as string

gConnectString = "Provider=MSDAORA;" & _
"Data Source=dd;" & _
"User ID=dd; " & _
"Password=dd; "

Connect = New OleDbConnection(gConnectString)
Connect.Open()

DA_County = New OleDbDataAdapter("Select CountyName Name, CountyNo ID
from ipt.tblcounty order by CountyName", Connect)
DA_County.Fill(DS_County)
DT_County = DS_County.Tables(0)

cboCty.ValueMember = "ID"
cboCty.DataSource = DT_County
cboCty.DisplayMember = "Name"

1. Try setting DisplayMember before setting the datasource.

2. Are you positive that "Name" is the proper column name?
 
Hi!
I did try both of your suggestions. None of them work. My code will work
fine for a SQL Server database but somehow it wouldn't work for Oracle
 
I assume that the underlying table has the data incorrectly filled as
displayed ? or is the problem somewhere in the binding ?

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
 
Hi!
I did try both of your suggestions. None of them work. My code will work
fine for a SQL Server database but somehow it wouldn't work for Oracle

Perhaps "Name" is some kind of reserved word in Oracle? Just for kicks,
try "[Name]".
 
the table is correctly filled with data. seems to me it is some kind of
binding problem.
 
I did try that but it still won't work. any other suggestions would be
appreciated

Thanks
 
Back
Top