Question How to use "AddNew" method

Rafis

New member
Joined
Jul 28, 2010
Messages
4
Programming Experience
Beginner
I need help in using AddNew() method, with DataGrid.
I have a VB.NET 2008 application, with a DataGrid in it.
I want the user to fill a form with some data. then I want to update the the DataGrid (data base is an Access table) with that data. I use the following code, but it does not enter any new row to my Grid.

Private Sub bindnavGrid_AddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bindnavGrid_AddNew.Click

Dim oRow As System.Data.DataRowView

Me.CustomersBindingSource.MoveLast()
'Add new record to recordsets
oRow = Me.CustomersBindingSource.AddNew()

oRow.BeginEdit()
With oRow
.Item("PROPOSAL") = sProposal_Number
.Item("CUSTOMER") = sCustomer_Name
.Item("CONTACTOR") = sContractor_Name
End With
oRow.EndEdit()

Me.CustomersBindingSource.EndEdit()
Me.FWQuotationsDataSet.AcceptChanges()

Me.CustomersTableAdapter.Update(Me.FWQuotationsDataSet.Customers)
Me.CustomersTableAdapter.Fill(Me.FWQuotationsDataSet.Customers)


End Sub
 
I don't quite understand what youre trying to do; the user can type into the grid directly - why are you trying to populate it for them? Using a phrase like "then I want to update the the DataGrid (data base is an Access table) with that data" leads me to believe you think there's a correlation between a DataGrid (an old control; we use DataGridView) and a database.. the two are disconencted..

If you could explain in high level english, what set of steps you want the user to take and what they see on screen at each step, it would help
 
Back
Top