SelectedValue weirdness in combobox tied to Access database

Under .NET 2.0 with Visual Studio 2005, I have a combobox on a form that is getting its data from an Access database. It's set up to display one column from the table and return another column's value when an item is selected. When I look at what's in SelectedValue, it contains two copies of the value from the database row. The row is not duplicated in the table, and it appears to be selecting the correct row. Does anyone have any hints as to what might be going on? I set up the associated dataset using the wizard, in case that matters.
LVL 1
ericamickAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Priest04Commented:
You should post some code in order to be helped. Like how do you set properties DisplayMember, ValueMember, DataSource, and with what parameters did you call comboBox.DataBindings.Add metod.
0
ericamickAuthor Commented:
I set DisplayMember, ValueMember, and DataSource through the form designer, and I don't call the DataBindings.Add method myself--I just let the designer do all that for me. My code simply stores the SelectedValue property's value in a private variable in the class during a button click event handler, and I access that value through a read-only property.
0
Priest04Commented:
So, if you dont give any code, how do you think we will be able to help you? If you say that databinding is done correctly, and you take the SelectedItem value correctly, then I dont see the reason why it should work. :)
0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

ericamickAuthor Commented:
Here's the code. Let me know what else you need.
Public Class CommAmdtList
    Private XMLFragment As String
 
    Private Sub CommAmdtList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'CommDataSet.CommitteeAmdt' table. You can move, or remove it, as needed.
        Me.CommitteeAmdtTableAdapter.Fill(Me.CommDataSet.CommitteeAmdt)
    End Sub
 
    Private Sub btnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOK.Click
        XMLFragment = AmdtList.SelectedValue
    End Sub
 
    ReadOnly Property XML() As String
        Get
            Return XMLFragment
        End Get
    End Property
End Class

Open in new window

0
ericamickAuthor Commented:
Here's one additional clue: The doubling of the value occurs only when the first item in the combo box is selected, i.e., SelectedIndex = 0.
0
Priest04Commented:
This is not the code I meant, I need, as I said in my first post, the code that you use to bind the combobox. If I understood you correctly

Private Sub btnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOK.Click
        ' this is the place where you load data from selected value
        XMLFragment = AmdtList.SelectedValue
        ' add one messagebox just so we can see what if the incorrect value is captured
        MessageBox.Show(XMLFragment)
End Sub

I need the code where you bind combobox. It is somewhere in the code behind the form, and never use designers, just becuase they usually cause trouble (like you are having now), so I cant tell where exactly did it put it.
0
ericamickAuthor Commented:
Here's the rest of the code, I think.
dataset.txt
form.txt
0
ericamickAuthor Commented:
It turns out the data in the database had the value duplicated, but I didn't realize it. Chalk up another one to user error.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Priest04Commented:
you should basically delete questions, since the post doesn't contain the actual answer, if someone else has the same problem. :)
0
Priest04Commented:
you should basically delete question, since the post doesn't contain the actual answer, if someone else has the same problem. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.