Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

combobox populated by combo box, need to message box the value

Posted on 2006-12-01
6
Medium Priority
?
176 Views
Last Modified: 2010-04-23
I need to Messagebox the valuemember (dealerId) from the database

this is my code for populating:

        Dim dt As New DataTable
        Dim ds As New DataSet


        Try
            da.Fill(dt)

        Catch ex As MySql.Data.MySqlClient.MySqlException
            MessageBox.Show(ex.Message)
        End Try

        ComboBox6.DataSource = dt
        ComboBox6.DisplayMember = "dealerName"
        ComboBox6.ValueMember = "dealerId"

if I messagebox combobox6.valuemember  I get dealerId as a string in my message box


I need to get the numberic Id
0
Comment
Question by:prowebinteractive
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 2000 total points
ID: 18055639
Accessing the .ValueMember property will only give you what field is being used as the value member...not the actual value selected.  Instead, try using the .SelectedValue property.
0
 

Author Comment

by:prowebinteractive
ID: 18055709
ok, in the database the value is eg: 00058, I get 58  howcome ?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 18055760
Hi prowebinteractive,

have you tried combobox.selectedvalue? if you are losing the 0, it is surely because it is converted to a numeric value


Cheers!
0
Industry Leaders: 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!

 

Author Comment

by:prowebinteractive
ID: 18055832
NOPE i DECLARED IT AS A STRING

BUT IN MYSQL AUTOINCREMENT ZEROFILL HAS TO BE INTEGER
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 18055902
prowebinteractive,

what is a string? it is really hard for us to try to help you with less then 10 lines of code? If dealerid is your autoincrement integer field, you will always get 58 instead of 00058 because VB drops the 0 on the left.
0
 

Author Comment

by:prowebinteractive
ID: 18055931
       Dim dealerId As String
        Dim today As Date
        Dim appSequence As String = "03"

        dealerId = ComboBox6.SelectedValue
        today = Date.Today

        Dim year As String = Mid(today, 9, 2)
        Dim month As String = Mid(today, 4, 2)
        Dim day As String = Mid(today, 1, 2)
        'MessageBox.Show(year)
        If dealerId = "" Then
            MessageBox.Show("ERROR! Creating account Number")
        End If

        MessageBox.Show(year & month & day & "-" & dealerId & "-" & appSequence)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

705 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