MySQL VB.NET Tutorial 10 :Database values in textbox if select Combobox




how to bind combobox to textbox in VB.NET ComboBox and TextBox VB.NET Visual Basic How to show combo box selected value in a text box VB.

source


26 responses to “MySQL VB.NET Tutorial 10 :Database values in textbox if select Combobox”

  1. Sir how about displaying a value into a textbox that came from a text box…
    example: texbox1 has a value of "2" and its value came from the selected row from the dataGridView that contains ID, Name, andPurchaseTotal, and the value that was displayed on that textbox1 will be displaying in another textbox…and the query is Select OldQuantities,OldUnitCost,OldTotal from tblPurchase where ItemID ='" + TextBox1.Text = +"'"
    BTW They are on the same Table
    Sorry for a long comment haha…TYIA

  2. Hi Sir, i have been following your videos for quite some time, basically some of my software i made i turn to your videos for reference most of the time. for this particular topic however i am having a problem since instead of using textboxes i transfer the output to labels like so:

    Label1.Text = READER.GetString("DB_Name")

    this works for a single row,, i am trying to grab the whole column with the rows that have the same data and display them in multiple labels.. any ideas on how to?,, thank you very much for a speedy reply

  3. I would also like to know if it is possible show employee picture to the form from the picture path that is stored in the sql server table. Please share if anyone has ideas of achieving this

  4. Hi, i try this to take 2 values

                While READER.Read
                    Dim Apellidos = READER.GetString("test1")
                    Dim Nombre = READER.GetString("test2")
                    ComboBox1.Items.Add(String.Format("{0} | {1}", test1, test2))
                End While

    But for the button what is the correct syntax ?????

    Query = "select test3 from xCantera.test where test1='" & ComboBox1.Text & "'"

    Thanks you…

  5. im trying to run my code in sql but its keeps saying this message "Conversion from string to type Integer is not valid"

    any advice, PLEASE HELP!!

    MysqlConn = New SqlConnection MysqlConn.ConnectionString = "Data Source=SABAHALI-SHEIKH;Initial Catalog=md_1103763;Integrated Security=True" Dim READER As SqlDataReader

        Try
            MysqlConn.Open()
            Dim Query As String
            Query = "select * from md_1103763.dbo.customer"
            COMMAND = New SqlCommand(Query, MysqlConn)
            READER = COMMAND.ExecuteReader
            While READER.Read
                Dim fName = READER.GetString("firstname")
                ComboBox1.Items.Add(fName)
            End While

            MysqlConn.Close()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            MysqlConn.Dispose()

        End Try

  6. Error

    Conversion from string "name" to type "integer" is not valid

    VS 2012

    +ProgrammingKnowledge  help me please

    Source :

    Imports MySql.Data.MySqlClient

    Dim MySqlConn As MySqlConnection
    Dim COMMAND As MySqlCommand

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    MySqlConn = New MySqlConnection
    MySqlConn.ConnectionString =
    "server=localhost;userid=root;password=;database=vbnetmysql"
    Dim READER As MySqlDataReader

    Try
    MySqlConn.Open()
    Dim Query As String
    Query = "Select * from vbnetmysql.edata "
    COMMAND = New MySqlCommand(Query, MySqlConn)
    READER = COMMAND.ExecuteReader

    While READER.Read
    Dim sName = READER.GetString("name")
    ComboBox1.Items.Add(sName) 
    End While

    MySqlConn.Close()
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    Finally
    MySqlConn.Dispose()
    End Try

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

    MySqlConn = New MySqlConnection
    MySqlConn.ConnectionString =
    "server=localhost;userid=root;password=;database=vbnetmysql"
    Dim READER As MySqlDataReader

    Try
    MySqlConn.Open()
    Dim Query As String
    Query = "Select * from vbnetmysql.edata where name='" & ComboBox1.Text & "'"
    COMMAND = New MySqlCommand(Query, MySqlConn)
    READER = COMMAND.ExecuteReader

    While READER.Read
    txtEid.Text = READER.GetInt32("eid")
    txtName.Text = READER.ToString("name")
    txtSurname.Text = READER.ToString("surname")
    txtAge.Text = READER.GetInt32("age")
    End While

    MySqlConn.Close()
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    Finally
    MySqlConn.Dispose()
    End Try

    End Sub

Leave a Reply