move row from one bound datagrid to another

Posted on 2011-10-07
Last Modified: 2012-05-12
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.
Question by:mmosoul
    LVL 10

    Expert Comment

    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

    Author Comment

    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
            End If

    Open in new window

    LVL 10

    Expert Comment

    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.
    LVL 10

    Accepted Solution

    Actually I've just re-read your code and there is a reference to a table adapter in the code (PoarchiveTableAdapter) the insert command may be on that table adapter.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now