Click here to Skip to main content
15,887,386 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The code I have is for individual tables I have it go through each one however, after a awhile I realized that the tables could be put into a dataset and referenced.

here is what I have:

Dim IDlibrary As DataSet = New DataSet("all_tables")
Dim Profileadaptor = New SqlDataAdapter
    Dim Deathadaptor = New SqlDataAdapter
 Dim cbpa As SqlCommandBuilder = New SqlCommandBuilder(Profileadaptor)
    Dim cbda As SqlCommandBuilder = New SqlCommandBuilder(Deathadaptor)

 Profileadaptor.SelectCommand = New SqlCommand("select * from " + "[Profile]", sqlconn1)
        Profileadaptor.SelectCommand.ExecuteNonQuery()
        Profileadaptor.Fill(profiledt)
        IDlibrary.Tables.Add(profiledt)

        Deathadaptor.SelectCommand = New SqlCommand("select * from " + "[Death]", sqlconn1)
        Deathadaptor.SelectCommand.ExecuteNonQuery()
        Deathadaptor.Fill(deathdt)
        IDlibrary.Tables.Add(profiledt)



after all changes, if any, I have a section just for those:

Dim changedtable As DataTable

changedtable = profiledt.GetChanges
        If Not IsNothing(changedtable) Then
            Profileadaptor.UpdateCommand = cbpa.GetUpdateCommand()
            Profileadaptor.Update(changedtable)
            Profileadaptor.Dispose()
        End If

        'death table
        changedtable = deathdt.GetChanges
        If Not IsNothing(changedtable) Then
            Deathadaptor.UpdateCommand = cbda.GetUpdateCommand()
            Deathadaptor.Update(changedtable)
            Deathadaptor.Dispose()
        End If



here is what I am aiming for to some degree:

For Each tab As DataTable In IDlibrary.Tables
           changedtable = tab.GetChanges()
           If Not IsNothing(changedtable) Then

           End If
       Next


what I am having an issue with is the sqldataadaptors, I need to somehow be able to access a list of saldataadaptors, but I do not know how. also I am not sure if I need the datatable change table, maybe it could be written
If Not IsNothing(tab.GetChanges()) Then
not sure.

What I have tried:

tried to make sqltableadaptor that could reference all adaptors, but I could not get that to work. I am hoping that someone can lead me down the right direction.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900