MarnieHook
asked on
Binding Textboxes. Will they update the database?
Hi there,
I am New At VB.Net.
I have a simple master detail form with some text fields, comboboxes and a datagrid.
I have several dataadapters making up a dataset.
eg.
POHEADER and PODETAIL are the two main tables used here, there are several other lookup tables.
Their DataAdapters are:
SqldaPOHEADER
SqldaPODETAIL
I have a DataSet called:
dsPurchaseOrder1
The dataset joins the two tables on 'PO_PONO'
The form is populating beautifully. The bound fields have all the correct values and the details table is populating with the correct details.
An example of the properties of one of the bound textbox fields is:
(Name) txtPoSuppAddr1
(Tag) DsPurchaseOrder1 - POHEADER.PO_PONO
(Text) DsPurchaseOrder1 - POHEADER.PO_SUPP_ADDR1
Now I want to make some changes on the form and update the database.
Here is the code:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
SqldaPOHEADER.Update(DsPur chaseOrder 1)
SqldaPODETAIL.Update(DsPur chaseOrder 1)
DsPurchaseOrder1.AcceptCha nges()
End Sub
Is there more to it than this?
Does VB.Net have this capability or do I have to do some more work to update the database?
Thanks again,
Marnie.
I am New At VB.Net.
I have a simple master detail form with some text fields, comboboxes and a datagrid.
I have several dataadapters making up a dataset.
eg.
POHEADER and PODETAIL are the two main tables used here, there are several other lookup tables.
Their DataAdapters are:
SqldaPOHEADER
SqldaPODETAIL
I have a DataSet called:
dsPurchaseOrder1
The dataset joins the two tables on 'PO_PONO'
The form is populating beautifully. The bound fields have all the correct values and the details table is populating with the correct details.
An example of the properties of one of the bound textbox fields is:
(Name) txtPoSuppAddr1
(Tag) DsPurchaseOrder1 - POHEADER.PO_PONO
(Text) DsPurchaseOrder1 - POHEADER.PO_SUPP_ADDR1
Now I want to make some changes on the form and update the database.
Here is the code:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
SqldaPOHEADER.Update(DsPur
SqldaPODETAIL.Update(DsPur
DsPurchaseOrder1.AcceptCha
End Sub
Is there more to it than this?
Does VB.Net have this capability or do I have to do some more work to update the database?
Thanks again,
Marnie.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Guys,
Thanks for the tips... I already had the update statement set etc. but it turns out that I needed to an EndEdit() on the row in the dataset before it recognised that there were any changes and updated the database.
Wierd. I didn't seee this anywhere in online help... luckily a girl in my training course came up with the solution. Not sure how I would have guessed this one!
dsOLEPurchaseOrder.Tables( "POHEADER" ).Rows(Bin dingContex t(DsPurcha seOrder1). Position). EndEdit()
Thanks again.
Marnie.
Thanks for the tips... I already had the update statement set etc. but it turns out that I needed to an EndEdit() on the row in the dataset before it recognised that there were any changes and updated the database.
Wierd. I didn't seee this anywhere in online help... luckily a girl in my training course came up with the solution. Not sure how I would have guessed this one!
dsOLEPurchaseOrder.Tables(
Thanks again.
Marnie.
If you dragged your data adapters on using server explorer in Visual Studio it should have created the Select, Update, Delete and Insert commands for you then as saleek mentioned you call the repsective command and the dataset you're affecting.
Good luck
BS