• Tuesday , 25 April 2017

MySQL VB.NET Tutorial 9 : How to Link Combobox with Database values



VB.Net: Filling a ComboBox with data stored in database how to bind combobox to textbox in VB.NET ComboBox and TextBox VB.NET How to show combo box …

source

Related Posts

35 Comments

  1. yort phonelanin
    April 21, 2017 at 20:48

    Thank You So much

  2. Anish Kumar
    April 21, 2017 at 20:48

    Thanks, very useful videos series

  3. Justin Shears
    April 21, 2017 at 20:48

    Hi Everyone!
    Just starting to learn VB.Net, I have gone through this lesson from start to finish, but cant seem to work out why I can't get mine to work!, I know it is different as I am using Sql not MySql, so trying to work out where I'm going wrong. At the point of …. While Reader.Read ; Dim sName = Reade.GetString("name ") I keep getting a InvalidCastException, any of you know what is going on???
    Thanks

  4. Alexis Rodriguez
    April 21, 2017 at 20:48

    Tried this for a access database and it comes out with syntax error in FROM Clause. Any clue?

  5. jan vincent segovia
    April 21, 2017 at 20:48

    what is the data type of your 'name' sir? my combobox cannot display items i don't know why.

  6. Redon Alla
    April 21, 2017 at 20:48

    Thank you, but I have a question
    when i try to insert date from Visual Basic Project to SQL Server 2008 with windows 7 I use '" & dateTipePiker.Text & "' it works when I use Windows 8 it don't work
    I tried '" & dateTipePiker.Value & "' and '" & dateTipePiker.Value.Date & "' and still dosen't work
    What should I do???

  7. Jayam Koko
    April 21, 2017 at 20:48

    thanks.. but after linking can i do like based on enter values in combobox put the value in the text box based on what saved in database

  8. Gelta Ponce da Motta Moreira
    April 21, 2017 at 20:48

    é nois mano <3

  9. Vibin As
    April 21, 2017 at 20:48

    Sir, when i run this code im getting the error as authentication to host''user'' using method'mysql close etc.
    what should i do to clear this error??
    Pls help

  10. faheem ullah
    April 21, 2017 at 20:48

    please make a tutorial on report with ms access database and mysql database
    show all report types

  11. Pepai Macatangay
    April 21, 2017 at 20:48

    its not working

  12. Marc Rey Inocente
    April 21, 2017 at 20:48

    Is there any sample code to download?

  13. Antonio Valle
    April 21, 2017 at 20:48

    What the code would be if I'm using Visula BAsic 2008???

  14. Servo Guy
    April 21, 2017 at 20:48

    Thanks

  15. Igor Oliveira
    April 21, 2017 at 20:48

    user need mysql to use program ?

  16. Igor Oliveira
    April 21, 2017 at 20:48

    hey what version of mysql use for this ?

  17. Amith Kulkarni
    April 21, 2017 at 20:48

    My Respect to your knowledge, very useful video, I am facing a challange in the similar arena, I have 2 tables, for ex. Customer Master and Supplier Master, the task is to populate Cust_Name field value and Supp_Name field value in single combo box… is it possible and how do I achieve this…? Many thanks in advance

  18. Oscar Ocampo Martinez
    April 21, 2017 at 20:48

    Thanks Al lot mate ! great tutorial

  19. Hassan Ksa
    April 21, 2017 at 20:48

    Thank you very match , great tutorial !

  20. Irfan Ahmed
    April 21, 2017 at 20:48

    Just in case anyone has trouble with Dim sName = Reader.GetString("name") then it is because your datatype in SQL server is not defined as a string. In my case it was varchar(50) so I changed the code to:
     
    Dim sName = Reader.GetString(0)

    0 = first column
    1 = second column
    2 = third column 
    and so on. 

    now it works.

  21. Propeller Inc
    April 21, 2017 at 20:48

    Conversion from string "PROP_Username" to type 'Integer' is not valid.
    I get this error on most of your tutorials and i don't know how to fix.

    It occurs on this code:

                    Dim sName = READER.GetString("PROP_Username")
                    SearchSQL.Items.Add(sName)

  22. Wesley
    April 21, 2017 at 20:48

    Hi, thanks for the programming tutorials, i have different tables in mysql database and would like to get the data from this tables to the same form in vb.net but on different combo boxes, kindly assist me with the solution. thanks in advance.
    i.e. i have a table that has patients details and another with doctors details, now i would love to get the patient ID and doctor ID in one form then save to another table e.g an admission table 

  23. S Sch
    April 21, 2017 at 20:48

    What, if i hav more Comboboxes? Can't get my code working!

  24. William Quick
    April 21, 2017 at 20:48

    Thanks!

  25. piyushsohal94
    April 21, 2017 at 20:48

    thanks for this video series. it has been very helpful to me.

  26. kane jeminico
    April 21, 2017 at 20:48

    okay guys to those who has problems with conversion error in getstring use this code

    dim "name of the value" = "name of the datareader".getstring(column number)

    dim sname = reader.getstring(2) // column 2 or name

  27. Katherine Santos
    April 21, 2017 at 20:48

    what if i want to filter the datagridview using that combobox, it's that possible???

  28. Joseph Langilao
    April 21, 2017 at 20:48

    THANK YOU!

  29. Roman Hadi
    April 21, 2017 at 20:48

    how can i populate my combo box when i need to get the value from 2 tables?

  30. Teufel964
    April 21, 2017 at 20:48

    Hi,

    thanks for your video. It works fine, but I have a problem. All item are dobble in the list, exakt 2 times.

            Dim cn As New MySqlConnection
            Dim cmd As New MySqlCommand
            Dim dr As MySqlDataReader
            cn.ConnectionString = "server = 192.168.2.50; user id = *; password = *; database = *"
            cmd.Connection = cn
            Try
                cn.Open()
                cmd.CommandText = "SELECT Nr, Name FROM goae Order by Nr;"
                dr = cmd.ExecuteReader
                While dr.Read
                    Dim Teil = dr.GetString("Nr")
                    cbb_go1.Items.Add(Teil)
                End While
                dr.Close()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "SQL-Fehler4",   MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
            Finally
                cn.Dispose()
            End Try
            cn.Close()
        End Sub

    It is start by 1 and go to 100 and begin a secound time by 1 and end by 100.
    Why ?
    Can you help me.

    Thanks

  31. Dim dimitris
    April 21, 2017 at 20:48

    Congrats for your videos series…the best found so far and you are the only one who explains exactly what you have in the descriptions…UNLIKELY SOME OTHER STUPIDS WHO just want to show themselves and in order to explain how much is 1+1 it takes them 10 mnutes of video!!!

  32. shekhar sharma
    April 21, 2017 at 20:48

    Getting Error 🙁 conversion from string  …. t0 type integer is not valid :'(

  33. 6274ks
    April 21, 2017 at 20:48

    hello. thanks for your video, nicely explained.
    but unfortunately, when i follow the code, this gives me error that "conversion from type string to integer is not valid"
    as i am trying to fetch the values from my database that are in the form varchar, and that GetString("tablename")
    where getString will fetch the data to integer as it shows in the VB IDE, so can you suggest another way around??
    help will be appreciated.
    NOTE: my backend is MS SQL server 2012

  34. flatpicker1234
    April 21, 2017 at 20:48

    Can you select an Item in your combobox and have it display the primary key in the database associated with the value in the combobox.text ?

  35. wawihackers hazardz
    April 21, 2017 at 20:48

    i still can fill the data into combo box…here the code…i hope u can check it..

    Imports MySql.Data.MySqlClient
    Imports System.Data.SqlClient
    Imports System.Windows.Forms
    Public Class Form10
        Dim con As MySqlConnection
        Dim cmd As New MySqlCommand
        Dim query As String
        Dim da As New MySqlDataAdapter

        Private Sub Form10_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            con.ConnectionString = ("server=Server=localhost;Database=einventorysystem;Uid=eisystem;password=password")
            Dim re As MySqlDataReader
            Try
                con.Open()
                query = "select * from einventorysystem.inventory"
                cmd = New MySqlCommand(query, con)
                re = cmd.ExecuteReader

                While re.Read
                    Dim iName = re.GetString("iname")
                    ComboBox1.Items.Add(iName)

                End While
                
                con.Close()

            Catch ex As Exception
                MessageBox.Show(ex.Message)
           Finally
               con.Dispose()
            End Try
            
        End Sub
    End Class

Leave A Comment

You must be logged in to post a comment.