0
Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
lblbrand.Text = ComboBox1.SelectedValue.ToString()
strb = lblbrand.Text
connetionString = "Data Source=HRS\SQLEXPRESS;AttachDbFilename='E:\My project\forms\1\1\mobile shop management.mdf';Integrated Security=True"
con = New SqlConnection(connetionString)
con.Open()
command = "select Model_id from mob where Brand ='" & lblbrand.Text & "'"
cmd = New SqlCommand(command, con)
Dim rd As SqlDataReader = cmd.ExecuteReader()
If rd.HasRows = True Then
While rd.Read()
ComboBox2.Items.Add(rd("Model_id"))
End While
End If
End Sub
哪里是它试图清除“以前的值”,并是否意味着选择的代码? – Plutonix 2014-10-31 16:54:19
始终为查询使用参数以避免sql注入。此外,您的HasRows检查是没有必要的。 – LarsTech 2014-10-31 18:00:10