Solved

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

Posted on 2006-12-01
6
170 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multiple file Upload asp.net 2 41
Visual Studio editor? 1 38
How to remove double quotes from a string in VB.Net 5 38
Close tabpage of custom control 9 24
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

862 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

24 Experts available now in Live!

Get 1:1 Help Now