Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I'm trying to update a modified DataSet using OleDb in Vb.Net.
I can get to the data and modify it, but I can't seem to be able to update the DateSet.
Problem seems to be with CommandBuilder, but I can't find a solution.

What I have tried:

VB
Dim i As Integer = 0
        Dim strA As String = ""
        Dim con As New OleDb.OleDbConnection
        Dim da As OleDb.OleDbDataAdapter
        Dim ds As New DataSet   'WIP Header Data
        Dim sql As String
        Dim DBprovider As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
        Dim DBSource As String = "Data Source = C:\Temp\TestDataBase.mdb"

        con.ConnectionString = DBprovider & DBSource

        con.Open()

        sql = "SELECT * FROM tblRecord"
        da = New OleDb.OleDbDataAdapter(sql, con)
        Dim cb As New OleDb.OleDbCommandBuilder(da)

        da.Fill(ds, "MyData")

        MaxRows = ds.Tables("MyData").Rows.Count

        Debug.Print(ds.Tables("MyData").Rows.Count)

        'Code to modify data in the DataSet goes here, ie:
        ds.Tables("MyData").Rows(0).Item("StandardName") = "Update Test"


        da.UpdateCommand = cb.GetUpdateCommand(True)

        da.Update(ds, "MyData")

        con.Close()
Posted
Updated 12-Dec-18 12:12pm
v2
Comments
[no name] 12-Dec-18 20:00pm    
And the error message is? *boared*
Member 14087495 12-Dec-18 20:27pm    
OleDbException was unhandled
Query is too complex
Richard MacCutchan 13-Dec-18 4:41am    
Where is the query that causes the problem?
Member 14087495 13-Dec-18 8:24am    
The exception is thrown when the da.Update(ds,"MyData") is executed.
Richard MacCutchan 13-Dec-18 9:34am    
Were is the actual text of the query?

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