我想问如何获取组合框的选定值,然后将其显示到多个文本框。组合框填充了数据库中的疾病。现在,当从组合框中选择一种疾病时,该疾病的症状应该显示在许多文本框中。目前我有 10 个用于症状的文本框。表结构是 id、disease、symbols。这是我的代码:
Dim mycmd As New MySqlCommand
Dim dtr As MySqlDataReader
Call Connect()
Dim str As String
str = "Select symptoms from diagnose where illness = @ill"
mycmd.Parameters.AddWithValue("ill", cmbRecord.Text)
mycmd.CommandText = str
dtr = mycmd.ExecuteReader
While dtr.Read()
symp0.Text = dtr("symptoms")
symp1.Text = dtr("symptoms")
symp2.Text = dtr("symptoms")
symp3.Text = dtr("symptoms")
symp4.Text = dtr("symptoms")
symp5.Text = dtr("symptoms")
symp6.Text = dtr("symptoms")
symp7.Text = dtr("symptoms")
symp8.Text = dtr("symptoms")
symp9.Text = dtr("symptoms")
End While
myConn.Close()
当从组合框中选择疾病时,症状应显示在这些文本框中。假设选定的疾病在表格中只有 4 个症状,然后文本框symp0
将symp3
一一显示症状,其余文本框留空。
The problem is that when an illness is selected, those textboxes displays only the last symptom of that illness stored in the database.
例如:发烧。在表中,它有4个症状:感冒、发热、头痛、头晕。如果选择发烧,则仅从symp0
到symp9
文本框显示头晕。