Solved

Displaying value member

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

13 Experts available now in Live!

Get 1:1 Help Now