R
Roshawn
Hi,
I have a form with textboxes that are bound to an untyped dataset (via the
BindingContext object). I also use the form's CurrencyManager and have
navigation buttons on the form. When the form is loaded, all data is
retrieved from the db and is displayed correctly in the textboxes. I'm also
able to navigate efficiently.
I'm having trouble adding a new row to my data table. Here's my code:
Private Sub AddData()
Dim dr As DataRow = ds.Tables("Members").NewRow()
With dr
.Item("FName") = txtFName.Text
.Item("LName") = txtLName.Text
.Item("Address") = txtAddress.Text
.Item("City") = txtCity.Text
.Item("State") = txtState.Text
.Item("Zip") = txtZip.Text
End With
ds.Tables("Members").Rows.Add(dr)
End Sub
The problems are:
1) the position of the CurrencyManager does not initally move to the new
row; instead it remains on the current row
2) the datarow is added to the table without permitting me to specify
desired data in the textboxes (I was under the impression that I could
modify data in the textboxes before the row was added to the table); instead
it just copies the data of the current row, thus creating duplicate data
What am I doing wrong? Is this the correct way to add a new row to a table
in a dataset or is there another way to do this? Any help will be
appreciated.
Thanks,
Roshawn
I have a form with textboxes that are bound to an untyped dataset (via the
BindingContext object). I also use the form's CurrencyManager and have
navigation buttons on the form. When the form is loaded, all data is
retrieved from the db and is displayed correctly in the textboxes. I'm also
able to navigate efficiently.
I'm having trouble adding a new row to my data table. Here's my code:
Private Sub AddData()
Dim dr As DataRow = ds.Tables("Members").NewRow()
With dr
.Item("FName") = txtFName.Text
.Item("LName") = txtLName.Text
.Item("Address") = txtAddress.Text
.Item("City") = txtCity.Text
.Item("State") = txtState.Text
.Item("Zip") = txtZip.Text
End With
ds.Tables("Members").Rows.Add(dr)
End Sub
The problems are:
1) the position of the CurrencyManager does not initally move to the new
row; instead it remains on the current row
2) the datarow is added to the table without permitting me to specify
desired data in the textboxes (I was under the impression that I could
modify data in the textboxes before the row was added to the table); instead
it just copies the data of the current row, thus creating duplicate data
What am I doing wrong? Is this the correct way to add a new row to a table
in a dataset or is there another way to do this? Any help will be
appreciated.
Thanks,
Roshawn