Solved

Displaying value member

Posted on 2006-11-14
4
209 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tabcontrol Caption? 1 31
VB.NET bulk update  of a table from another table 4 36
Exit the loop 4 37
Variable Event ? 3 23
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now