?
Solved

Displaying value member

Posted on 2006-11-14
4
Medium Priority
?
217 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 2000 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

Technology Partners: 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

850 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