Newbie: Adding new rows to dataset

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
 
M

Miha Markic

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.
 
N

Nathan

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top