none
Updet Dataset in dataset.Relations table RRS feed

  • Question


  • Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Xml
    Imports System.IO
     
    Module Module1

        Dim Ds As New DataSet

        Dim sqlDataAdapter_ As SqlClient.SqlDataAdapter
     

        Private Sub Load_Datagird()

     

            Dim sqlConn As New SqlClient.SqlConnection(strConn1)

     

            'Khai báo phần hiện tự dộng hàng loạt các bảng

     

            sqlDataAdapter_= _

                New SqlClient.SqlDataAdapter( _

                "Select ID_Doc, Note from Doc", sqlConn)

     

     

            Dim sqlCmdBuilder As SqlClient.SqlCommandBuilder

     

            sqlCmdBuilder = _

                New SqlClient.SqlCommandBuilder(sqlDataAdapter_)

     

            sqlDataAdapter_.Fill(Ds, "Table")

     

            sqlDataAdapter_= _

            New SqlClient.SqlDataAdapter( _

            "Select ID_House, ID_Doc, Note from  DOC_house", sqlConn)

     

            sqlCmdBuilder = _

                New SqlClient.SqlCommandBuilder(sqlDataAdapter_)

     

            sqlDataAdapter_.Fill(Ds, "Table_1")

     

            'sqlDataAdapter_.Fill(Ds_KhoHồSơTàiLiệu, "Table_1")

     

            Ds.Relations.Add("DocStore", _

            Ds.Tables("Table").Columns("ID_Doc"), _

            Ds.Tables("Table_1").Columns("ID_Doc"))

     

            sqlDataAdapter_= _

            New SqlClient.SqlDataAdapter( _

            "Select ID_Sell, ID_Doc, Note from  Doc_sale", sqlConn)

     

            sqlCmdBuilder = _

                New SqlClient.SqlCommandBuilder(sqlDataAdapter_)

     

            sqlDataAdapter_.Fill(Ds, "Table_2")

     

            Ds.Relations.Add("DocSell", _

            Ds.Tables("Table").Columns("ID_Doc"), _

            Ds.Tables("Table_2").Columns("ID_Doc"))

     

      


            End sub
      Private Sub OvalButton_Update_DoubleClick(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles OvalButton_ Update.DoubleClick
            sqlDataAdapter.Update(Ds, "Table_1") // Why update? Mising datacolum ‘ID_Sell’ in the Table_1 
    End sub
     
    End Module
    Monday, August 6, 2007 4:42 AM

All replies