Solved

Displaying value member

Posted on 2006-11-14
4
213 Views
Last Modified: 2008-03-06
In the code below I wanted to display the strAssistanceDesc in the combo box but have the lngAssistanceid as the value that is reterived.  this code is displaying 1 which is the lngAssitanceid, how can I get it to display the name instead.

thank you

Dim cmd6 As New SqlClient.SqlCommand("Select * from tbllkpMHCPAssistance", Connection1)
        Try
            cmd6.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Dim da As New SqlDataAdapter(cmd6)
        Dim ds As New DataSet
        da.Fill(ds, "tbllkpMHCPAssistance")
        me.ComboBox5.DataSource = ds.Tables("tbllkpMHCPAssistance")
        Me.ComboBox5.DisplayMember = "strAsstistanceDesc"
        Me.ComboBox5.ValueMember = "lngAssistanceid"
0
Comment
Question by:running32
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 17938311
Hi running32,

Its a funny thing, when you try to bind a field to the valuemember that doesn't exist, it throws an error. When you try to bind a field that doesn't exist to the displaymember ....... it shows the valuemember instead without throwing an error.

In your case I am willing to bet that if you change the line         Me.ComboBox5.DisplayMember = "strAsstistanceDesc" to spell "strAssistanceDesc" correctly all your problems will go away.


Tim Cottee
0
 

Author Comment

by:running32
ID: 17938466
thanks, but how do I get the valuemember and not the displaymember calling the contents.  I am using ComboBox5.text but I am getting Pass instead of 1 (the value member) Thanks
0
 

Author Comment

by:running32
ID: 17938556
thanks
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 17938557
running32,

You use ComboBox5.SelectedValue to return the valuemember associated with the item.

Tim
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question