我无法弄清楚我的问题是没有错误,但组合框中的值没有从mysqldatabase显示 这是我的代码
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim conn As New MySqlConnection
conn.ConnectionString = "server=localhost;user vbid=root;password=admin;database=dnidb"
Dim reader As MySqlDataReader
Try
conn.Open()
Dim query As String
query = "select * from dnidb.hargapro where NamaP = '" & ComboBox1.Text & "'"
command = New MySqlCommand(query, conn)
reader = command.ExecuteReader
While reader.Read
TextBox8.Text = reader.GetInt32("HargaP")
End While
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
conn.Dispose()
End Try
End Sub
这段代码没有错误,但没有在组合框中显示任何内容,我尝试在combobox_selectedindexchanges上制作这个锥体,同样的东西没有出现在组合框中
我只是按照这里的代码 https://www.youtube.com/watch?v=HfnoGEmRGvc
答案 0 :(得分:1)
我没有看到任何试图将产品名称检索到组合框的代码,看起来上面的代码应该在组合框的SelectedIndexChanged事件中。