Hello!
I am able to add new records to a database and then update the access database, but i can't get it to update exisitng rows.
Here is the code i tried:
Here is the message:Code:Private Sub UpdateCPHeaderFooter() Dim dacmt As OleDb.OleDbDataAdapter Dim cb As OleDbCommandBuilder Dim con As OleDbConnection Dim sql As String Dim r() As DataRow Dim dr As DataRow Dim arr(4) As String r = dsCPHeadFoot.Tables(My.Settings.CMTCPHeadFoot).Select("ID = '" & CPID & "'") If r.Length <> 0 Then r(0).Item(1) = txtHeader.Text r(0).Item(2) = txtFooterLeft.Text r(0).Item(3) = txtFooterMid.Text r(0).Item(4) = txtFooterRight.Text con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & My.Settings.CMTCONSTRING & ";") sql = "Select * from " & My.Settings.CMTCPHeadFoot dacmt = New OleDb.OleDbDataAdapter(sql, con) cb = New OleDbCommandBuilder(dacmt) dacmt.Update(dsCPHeadFoot, My.Settings.CMTCPHeadFoot) dacmt = Nothing con.Close() con.Dispose() dsCPHeadFoot.AcceptChanges() End If End Sub
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.




Reply With Quote