display new rec in datagrid on mdi form?

A

Adda

I have a datagrid on a parent mdi form with connection1,
dataAdapter1, dataset1. From a main menu I call a child
form where I enter new data and update dataset1 with
dataAdapter2, connection2 on the child form, but the same
dataset (dataset1). The data is stored in a sql server DB
and is being stored correctly, but the new record is not
being displayed in the datagrid on the parent form. If I
close the app and re-open it, I can see the new record in
the datagrid. How can I refresh the datagrid on the
parent form without having to close and re-open the app?

TIA
Adda
 
A

Adda

I came up with two solutions. One is to add an additional
menu to the parent form where I clear the dataset and
refill it with the dataAdapter for the parent form. My
other solution is to open the child form as a Dialog form
(modal form) and use the Parent form dataset and
dataAdapter to add the new row. I also tried referencing
the Parent from dataset in the child form . But this did
not seem to update the datagrid in the parent form even
though it did add the record to the database.

Sub AddNewRec(...)...
Dim dr as datarow, frm as New ParentFrm
dr=frm.dataset1.Tables("tbl1").NewRow()
dr(0) = txt0.Text
dr(1) = txt1.Text
frm.dataset1.Tables("tbl1").Rows.Add(dr)
frm.dataAdapter1.Fill(dataset1, "tbl1")
End Sub

I also tried refilling dataset1 with
frm.dataAdapter1.Fill... from the child form. But no
effect. Is it even possible to control a parent form from
a child form like this?
 

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