Solved

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

Posted on 2006-12-01
6
174 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 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 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

630 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