Solved

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

Posted on 2006-12-01
6
169 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
  • 3
  • 2
6 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 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 69

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

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

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

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now