Solved

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

Posted on 2006-12-01
6
173 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
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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