我有 vb.net 应用程序表单,它包含 id 作为组合框。单击编辑按钮并选择其他ID后,我发现错误如下图所示。那该怎么办?
Private Sub searchparfum()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter("select num from parfum", MaConnection)
da.Fill(dt)
Dim r As DataRow
cmb_parfum.AutoCompleteCustomSource.Clear()
For Each r In dt.Rows
cmb_parfum.AutoCompleteCustomSource.Add(r.Item(0).ToString)
Next
cmb_parfum.AutoCompleteMode = AutoCompleteMode.SuggestAppend
cmb_parfum.AutoCompleteSource = AutoCompleteSource.CustomSource
End Sub
Private Sub cmb_parfum_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_parfum.SelectedIndexChanged
qry = "select * from parfum where num ='" & (cmb_parfum.Text) & "' "
cmd = New OleDbCommand(qry, MaConnection)
cmd.ExecuteNonQuery()
dr = cmd.ExecuteReader
If dr.Read Then
txt_num.Text = dr("num")
lab_nom.Text = dr("nom")
lab_prix.Text = dr("prix")
stock_par.Text = dr("stock")
txt_ventes.Text = dr("ventes")
photo.Text = dr("photo")
End If
End Sub