M
Martin Horn
Hi all,
I am using VB2005 and the new data controls, which all work fine, except
there is a situation where I want to add a new row to the database without
using the 'AddNewItem' button on the BindingNavigator control; it has to be
done programatically.
This is the best I can come up with but it fails on line 3 with error
'Objects added to a BindingSource's list must all be of the same type.'
Dim dt As New MainDataSet.InvoicesDataTable
Dim dr As MainDataSet.InvoicesRow = dt.NewInvoicesRow
InvoicesBindingSource.Add(dr) <Error here>
' Set field values here
dr.field1 = 1
dr.field2 = ...etc
' Save the new row to the database
InvoicesBindingSource.EndEdit()
InvoicesTableAdapter.Update(MainDataSet.Invoices)
Any advice will be appreciated.
Thanks very much,
Martin Horn.
I am using VB2005 and the new data controls, which all work fine, except
there is a situation where I want to add a new row to the database without
using the 'AddNewItem' button on the BindingNavigator control; it has to be
done programatically.
This is the best I can come up with but it fails on line 3 with error
'Objects added to a BindingSource's list must all be of the same type.'
Dim dt As New MainDataSet.InvoicesDataTable
Dim dr As MainDataSet.InvoicesRow = dt.NewInvoicesRow
InvoicesBindingSource.Add(dr) <Error here>
' Set field values here
dr.field1 = 1
dr.field2 = ...etc
' Save the new row to the database
InvoicesBindingSource.EndEdit()
InvoicesTableAdapter.Update(MainDataSet.Invoices)
Any advice will be appreciated.
Thanks very much,
Martin Horn.