Newbie: Adding new rows to dataset

  • Thread starter Thread starter Nathan
  • Start date Start date
N

Nathan

Hi,

I have a data-entry type form I created with textboxes bound to a dataset.
I can successfully pull all the correct information up and change any
existing data, and navigate through each record using the
BindingManagerBase.Position. What I'm trying to do now is add a row to the
dataset and then move to that row with the form to add new information.
I've tried declaring a new row and adding it to the dataset, as well as
doing BindingManagerBase.AddNew. Each of these adds a row to the dataset,
but I can't get it to show on the form. When I close the form, the database
is updated, and the new row appears in the database table correctly. How do
I get the form to show the added row?

Thanks,
Nathan
 
Hi Nathan,

No need to add a row to dataset.
It is enough if you do BindingManagerBase.AddNew and it should position on
new row automatically.
 
I've gone back and tried it, and now I'm not able to get
BindingManagerBase.AddNew to work at all. After the Designer Generated Code
I have "Dim bmb as BindingManagerBase", and in the frm_Load event I put "bmb
= Me.BindingContext(DatSet, "Table")". Then the btnNew click event has
only:

bmb.EndCurrentEdit()
bmb.AddNew()

Nothing happens at all.

Furthermore, my btnLastQuestion click event says only "bmb.Position =
bmb.count-1" This works fine until I click btnNew. I put a
Msgbox(bmb.Count.ToString) in the btnLastQuestion click event, and it shows
that a new row is being added to the bmb each time I click btnNext. But it
doesn't go there, nor will it save it to the database with the update
command.

Surely I'm missing something?
 
Back
Top