Popular Posts

VB.Net Display MySQL Data Depending On Combobox Value

Share it:

How To Show Values From MySQL DataBase Based On ComboBox Value In VbNet

VB.Net Display MySQL Database Values Based On Combobox Value

In This VB.Net Tutorial  We Will See How To Display Data From MySQL DataBase And Set Vaues Into TextBoxes And DateTimePicker According To ComboBox Selected Value Using   Visual Basic.Net Programming Language And Visual Studio Editor.


Project Source Code:

Imports MySql.Data.MySqlClient

Public Class Display_Data_From_MySQL_Depending_On_Combobox_Value

    Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=")

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

        ' fill combobox from database using MySqlDataAdapter

        Dim adapter As New MySqlDataAdapter("SELECT `Id` FROM s_t_d.student", connection)
        Dim table As New DataTable()

        adapter.Fill(table)

        ComboBox1.DataSource = table

        ComboBox1.ValueMember = "Id"
        ComboBox1.DisplayMember = "Id"

    End Sub

    Private Sub ButtonShow_Click(sender As Object, e As EventArgs) Handles ButtonShow.Click

        Dim adapter2 As New MySqlDataAdapter("SELECT `Id`, `FullName`, `Address`, `BirthDate` FROM s_t_d.student WHERE id=" & ComboBox1.SelectedValue, connection)
        Dim table As New DataTable()

        adapter2.Fill(table)

        TextBox1.Text = table(0)(1)
        TextBox2.Text = table(0)(2)
        DateTimePicker1.Value = table(0)(3)

    End Sub
End Class
      
///////////////OUTPUT:

Show Data From MySQL Based On ComboBox Using Vb.Net




Share it:

combobox

database

Display MySQL Database Data Depending On Combobox Value In VB.Net

mysql

mysql database

VB.NET

vb.net combobox

Post A Comment:

0 comments: