Now, i have Set up the Connection to MySQL,and i have this Layout:

|ID|Class|Name|Password|

The Names are ALL shown in Combobox2.But i have a Combobox1 with Numbers.Now if i select 1, i want only the Users with Class 1 to show in my Combobox2,when i Select 2, only Class 2 and so on. Also, i want the Programm to check the Password. What could i use to make this all happen? I also have a DataGridView if it helps. My code:

Dim conn As New MySqlConnection
        Dim myConnectionString As String
        myConnectionString = "server=127.0.0.1;uid=root;pwd=banana;database=kinder; "
        conn.ConnectionString = myConnectionString
        Try
            conn.Open()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        Dim com As String = "Select * from kind"
        Dim Adpt As New MySqlDataAdapter(com, conn)
        Dim ds As New DataSet()
        Adpt.Fill(ds, "kind")
        DataGridView1.DataSource = ds.Tables(0)
        Dim strSQL As String = "SELECT name FROM kind"
        With ComboBox2
            .DataSource = ds.Tables("kind")
            .DisplayMember = "name"
            .SelectedIndex = 0
        End With           

Thx in Future

Recommended Answers

All 3 Replies

Hi! Sponge_1
to do that first you have to fill combobox1 with class field of your database.
Then search your database on selection of class from combobox1 and you have to do this withen Combobox1.SelectionChange Event.

But i never integrated MySQL before.can you give me a example Snippet of code?

Also,i have duplicate classes,because there are multiple users in a class.how to fix that?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.