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


35 responses to “MySQL VB.NET Tutorial 9 : How to Link Combobox with Database values”

  1. 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

  2. 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???

  3. 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

  4. 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.

  5. 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)

  6. 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 

  7. 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

  8. 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

  9. 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!!!

  10. 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

  11. 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 Reply