How to insert a datas from datagrid tha already having the source binding with other the table in the same database?

Locked How to insert a datas from datagrid tha already having the source binding with other the table in the same database?

  • Tuesday, July 24, 2012 3:58 PM
     
      Has Code

    How to insert a datas from datagrid tha already having the source binding with other the table in the same database?I m doing a huge project in there i m having a form its already the controls (including data-grid view) is binded with a table and retrieving the data and doing insert and update too. but same time from the data grid view, i need to insert data to a another table from the database. how to do it?

    Me.Inv_grnitemTableAdapter.Fill(Me.Matrix_inv_dbDataSet.inv_grnitem)
    Me.Inv_purchaseorderitemsTableAdapter.Fill(Me.Matrix_inv_dbDataSet.inv_purchaseorderitems)
    Me.Inv_purchaseorderTableAdapter.Fill(Me.Matrix_inv_dbDataSet.inv_purchaseorder)

    above datasets and table adapters are used and one datagrid view is used....

All Replies

  • Wednesday, July 25, 2012 6:07 AM
    Moderator
     
     

    Hi andrewpraveen,

    Welcome to the MSDN forum.

    This is a VB IDE forum. Your topic about datagrid issue is out of scope here. Pay attention that datagrid is a Web UI control. If this is an ASP.Net issue, please connect the ASP.net forums with this link: http://forums.asp.net/. If this is a VB.Net issue, I will move this thread to VB general forum.

    There is no different between add the records to the different datatable. You can choose the specific data table in SQL query. As for the data, you need to change the data to suit for the structure of new data table.

    I look forward your reply.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

  • Sunday, July 29, 2012 2:25 AM
     
     Answered

    For co = 0 To DataGridView.Rows.Count - 1
    Me.TableAdapter.Insert((DataGridView.Rows(co).Cells(0).Value).ToString, (DataGridView.Rows(co).Cells(1).Value).ToString)
    Next

    Simply the inserting query for the table adapter and count the gridview rows and insert one by one.

    • Marked As Answer by andrewpraveen Sunday, July 29, 2012 2:25 AM
    •