title: How to display data from mysql base from Dropdownlist selection
body: <p>i want to display mysql data base from the dropdownlist. i populate data from dropdownlist using this code and it works perfectly. in this code it will show the productnames in the dropdownlist</p>
  <pre><code>If Not Me.IsPostBack Then
              Dim constr As String = ConfigurationManager.ConnectionStrings(&quot;constr&quot;).ConnectionString
              Using con As New MySqlConnection(constr)
                  Using cmd As New MySqlCommand(&quot;SELECT tbl_productid,tbl_productname FROM tbl_products&quot;)
                      cmd.CommandType = CommandType.Text
                      cmd.Connection = con
                      con.Open()
                      cmbProducts.DataSource = cmd.ExecuteReader()
                      cmbProducts.DataTextField = &quot;tbl_productname&quot;
                      cmbProducts.DataValueField = &quot;tbl_productid&quot;
                      cmbProducts.DataBind()
                      con.Close()
                  End Using
              End Using
              cmbProducts.Items.Insert(0, New ListItem(&quot;Select Product&quot;))
          End If
  </code></pre>
  <p>Now base from the selected product name i want to display its productID to textbox. but this code gives me no output? i dont know what is wrong with my code anyone who can help me</p>
  <p>This is code</p>
  <pre><code> Protected Sub cmbProducts_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cmbProducts.SelectedIndexChanged
          'MsgBox(&quot;Hellow World!&quot;, MsgBoxStyle.Critical)
          Dim constr As String = ConfigurationManager.ConnectionStrings(&quot;constr&quot;).ConnectionString
          Dim con As New MySqlConnection(constr)
  
  
  
          con.Open()
          Dim cmd As New MySqlCommand(&quot;SELECT tbl_productid from tbl_products where tbl_productname = '&quot; + cmbProducts.Text + &quot;'&quot;, con)
          Dim sda As New MySqlDataAdapter(cmd)
          'Dim dr As New MySqlDataReader
          Dim dr As MySqlDataReader
          dr = cmd.ExecuteReader
  
          If dr.Read Then
              txtProductID.Text = dr.GetValue(0)
          End If
  
          con.Close()
          con.Dispose()
  
  
      End Sub
  </code></pre>