i am working on a POS as a school project. im having a problem in getting the stocks, which is a record in my database.
this is what i need to do, i need to populate the combobox with drug names with suggests. when i choose a certain drug, its stocks will be displayed on a textbox as a reference.
this is what ive done so far:
Private Sub posform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load accountlbl.Text = mainmenu.namelbl.Text dbconnect() Dim suggest As New SqlCommand("select prodname from productinfotbl ", connect) suggest.CommandType = CommandType.Text adapt.SelectCommand = suggest adapt.SelectCommand.ExecuteNonQuery() adapt.Fill(dset, "suggests") ComboBox1.DataSource = dset.Tables("suggests") ComboBox1.DisplayMember = "prodname" ComboBox1.ValueMember = "prodname" ComboBox1.AutoCompleteSource = AutoCompleteSource.ListItems ComboBox1.AutoCompleteMode = AutoCompleteMode.Suggest
i was able to populate the combobox with this but the error strikes when i put this code so i can fetch other data when i change the value of the combobox:
dbconnect() Dim sql As New SqlCommand("select * from productinfotbl where prodname='" & ComboBox1.Text & "'", connect) sql.CommandType = CommandType.Text adapt.SelectCommand = sql adapt.SelectCommand.ExecuteNonQuery() adapt.Fill(dset, "prods") dc() stocktbx.Text = dset.Tables("prods").Rows(0).Item("stocks")
it shows the ff error message:
An exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll but was not handled in user code