Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   VB .NET Access update error (http://www.go4expert.com/forums/vb-net-access-update-error-t16874/)

casewolf 11Apr2009 08:30

VB .NET Access update error
Hi, I am new to this whole forum thing so please bear with me.
I am writing a program in VB.NET that uses a Microsoft Access database. I can import it into a dataset just fine. Edit the dataset but when I have to program try to update the database with the changes it will only update the first table and then throw me an error when it gets to the second table:"" Missing the DataColumn 'CustomerName' in the DataTable 'Job' for the SourceColumn 'CustomerName'."" I should explain that my database has several tables (garyType is actually an array of the table names) and that each table has several columns. 'CustomerName' is only in the "Customer" table however and not in the "Job" table (which is what is trying to be updated on the second run of the For loop.
Code: VB

Dim garyType() As String = {"Customer", "Job", "CustomerType", "DateDelivered", "SiteManager", "Driver", "Material"}
        If gDevLogDataSet.HasChanges Then
            updateDevLog = gDevLogDataSet.GetChanges() 
            For i As Integer = 0 To (garyType.Length - 1)
               strSQLFull = "SELECT * FROM " & garyType(i)
                oleDevLogUpdate.SelectCommand = New OleDb.OleDbCommand(strSQLFull, oleConnection)
                oleDevLogUpdate.Update(gDevLogDataSet, garyType(i))
[I] 'On the second run through the loop the error message that comes up while trying to run this line of code is:  Missing the DataColumn 'CustomerName' in the DataTable 'Job' for the SourceColumn 'CustomerName'  [/I]             
        End If

I should mention that if only one table is being updated then the code works fine - no matter which table is being updated. But I should also mention that even when I get rid of the loop and just try to update each table individually it still throws the same error on the second table being updated.
Thank you for your time.

All times are GMT +5.5. The time now is 03:41.