Solved

Displaying value member

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 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