Hi, i am new on vb.net and MySql, and i have a problem.

My database name is "plant3", i have a table named "itemlist" which has a field named
"itemname", "task", and "status". I want to show the itemname on combobox and when user choice an itemname the program will show all task and status for that item.

Someone please help me..

you can use displaymember and valuemember proprties of combobox.
For e.g.

---first Open the connection

connection.OPen();
Dim dt as DataTable,sql as string
sql="Select ID,Name from emplayee;"
MysqlDataAdpter Adpter=new MysqlDataAdapter(sql,Connection);
--fill the Datatable with the Data.
Adpter.Fill(dt)

--Now Combo BOx
Combobox1.DataSource=dt;
Combobox1.DispalyMember="ID"
Combobox1.ValueMember="Name"

--When you run the programm. combobox display the name of employee and when you select any name then you can takes it value as a Index

i get this error "data isnot show"
this is my code:
--------------------------------------------------------------------------------
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

Dim itemname As String = ComboBox1.SelectedText


Dim conn As MySqlConnection
Dim reader As MySqlDataReader = Nothing
Dim cmd As New MySqlCommand

conn = New MySqlConnection
conn.ConnectionString = "server=localhost; user id=root;password=; database=plant3"
cmd.Connection = conn
cmd.CommandText = "SELECT itemname, task, status FROM itemlist where itemname=@itemname"
cmd.Parameters.Add("@itemname", MySqlDbType.VarChar).Value = itemname
conn.Open()

Try
reader = cmd.ExecuteReader()
If reader.Read() Then

MessageBox.Show("data is show")
TextBox1.Text = reader.GetString(0)
TextBox2.Text = reader.GetString(1)
TextBox3.Text = reader.GetString(2)
End If
Catch ex As Exception
MessageBox.Show("failed to populate database list : " + ex.Message)
Finally
If Not reader Is Nothing Then reader.Close()
MessageBox.Show("data isnot show")
End Try
End Sub

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.