I have a database that currently has nothing in it and I’m trying to create and save the first record, but end up getting an error that says “There is no row at position 0.”
What I’ve done is instead of having a textbox that allows a user to select a shipper or receiver name, I’ve pulled those out and put in comboboxes that I’ve bound to the appropriate field in two other databases (shippers.mdb and receivers.mdb).
So, on clicking the “save” button, I want to save the selecteditems (saved to strings) from those comboboxes to each column cell in the database that I want. However, the system isn’t letting me save the record at all. I’ve been trying to figure out how to save the information for the “current” record being edited or entered so for some reason I’ve decided to use (0), thinking that might work but it seems that isn’t right. Here is the code:
Private Sub Button16_Click_1(sender As System.Object, e As System.EventArgs) Handles Button16.Click
Me.OrdersDataSet.orders(0).orderstatus = ComboBox13.SelectedItem.ToString()
shipper1 = ComboBox8.SelectedItem.ToString()
Me.OrdersDataSet.orders(0).SHIPPER1 = shipper1
RECEIVER1 = ComboBox9.SelectedItem.ToString()
Me.OrdersDataSet.orders(0).RECEIVER1 = RECEIVER1
billtoacct = ComboBox7.SelectedItem.ToString()
Me.OrdersDataSet.orders(0).BILLTOACCT = billtoacct
driverassigned = ComboBox10.SelectedItem.ToString()
Me.OrdersDataSet.orders(0).DRIVERASSIGNED = driverassigned
truckassigned = ComboBox11.SelectedItem.ToString()
Me.OrdersDataSet.orders(0).TRUCKASSIGNED = truckassigned
trailerassigned = ComboBox12.SelectedItem.ToString()
Me.OrdersDataSet.orders(0).TRAILERASSIGNED = trailerassigned
Me.Validate()
Me.OrdersBindingSource.EndEdit()
Me.TableAdapterManager12.UpdateAll(Me.OrdersDataSet)
End Sub
What should I be using instead because I can’t seem to find something to let me save (or substitute) the combo box items for the current record? I did check in the table adapter that the CRUD is there and I went through to make sure it’s set up to fill, update, etc.
Thanks for having a look.
Give this a shot…. PUT ALL OF THIS IN YOUR BUTTON CLICK EVENT AND CHANGE AS NEEDED…
Then you have your dataset with the table and your data to set to your table adapter manager
Thanks!