Link to home
Start Free TrialLog in
Avatar of mmosoul
mmosoul

asked on

move row from one bound datagrid to another

I have 2 data grids bound to an access database with binding sources and navigators.  The main data has an auto generated number for the index.  The archive data has the index set to number.  I want to use the same number from the main data because that is the unique ID for that information.  When I try to copy the row to the archive and delete it from the main I get an error that the index column can't contain a null value when trying to update the archived data.  The ID column has the number from the main data in the cell so this is very confusing.  The archive has additional columns in it for dates so it's not a direct copy of the row but all of the information is in the cells before it tries to save.
Avatar of gavsmith
gavsmith
Flag of United Kingdom of Great Britain and Northern Ireland image

Have you double checked that the insert command includes the ID column for the archive table, also how is the ID column setup for the archive table? To debug this you could allow all the columns in the archive table to allow nulls, then take a look at the table after inserting a row from the main table.

Hope that helps
Avatar of mmosoul
mmosoul

ASKER

How do I look at the insert command?  It's bound data with a navigator.  I press the add row button, enter the data then press the save button.  I don't pass it any insert commands or anything.

Save button:
        If Me.Validate() = True Then
            Me.PoarchiveBindingSource.EndEdit()
            Me.PoarchiveTableAdapter.Update(Me.PolistDataSet.poarchive)
        End If

Open in new window

If you have used the wizards to create a binding datasource you (most likely, there are several different ways) may have created a dataset, so in your solution explorer you may have 'DatabaseNameDataSet.xsd'?

If so, expand that and you'll see 'DatabaseNameDataSet.Designer.cs' if you open that and look at InitAdapter, specifically the line the starts:

this._adapter.InsertCommand.CommandText = @"INSERT INTO

you should see your insert command and below the parameters that are getting passed to it.

P.S I'm making a lot of assumptions as to how you have set this up... please let me know if I'm wrong.
ASKER CERTIFIED SOLUTION
Avatar of gavsmith
gavsmith
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial