Dear all,
I found a way to make it work, but not sure if in the end it will not creating problems, like difference of collumn / row between DS and the Database. If then the Dataset, Dataadapter and Database are in sync.
I now have combined ds.tables with a query for insert. ds.tables is/was already updated in the above code. But I run in problem with da.update and for this da.update I want to use a query, so I have then;
Private Sub BtnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
Dim query As String
Dim i As Integer
Try
dsNewRow = ds.Tables("UsersDB").NewRow()
dsNewRow.Item("rwUser") = txtNaam.Text
dsNewRow.Item("rwInlogName") = TxtGeboorteplaats.Text
ds.Tables("UsersDB").Rows.Add(dsNewRow)
query = "INSERT INTO tbLocalDataFolder (rwDatabase,rwLocation) VALUES ('" & txtNaam.Text & "','" & TxtGeboorteplaats.Text & "')"
executquery(query, con)
dsNewRow.Item("rwDatabase") = txtNaam.Text
dsNewRow.Item("rwLocation") = TxtGeboorteplaats.Text
ds.Tables("LocalDB").Rows.Add(dsNewRow)
query = "INSERT INTO tbLocalDataFolder (rwDatabase,rwLocation) VALUES ('" & txtNaam.Text & "','" & TxtGeboorteplaats.Text & "')"
executquery(query, con)
Catch ex As Exception
Dim s As String
s = ex.StackTrace
End Try
End Sub
Public Sub executquery(query As String, connec As OleDb.OleDbConnection)
Dim commandOleDb As New OleDb.OleDbCommand(query, connec)
con.Open()
commandOleDb.ExecuteNonQuery()
con.Close()
End Sub