How do I update an MS-Access recordset using VB.NET?
I’ve basically to update a field which has id of 1, and field value for ‘ticker’ is ‘UKX’.
The data to be updated is in the ‘value’ field and comes from a Public Sub. dLast is the data which I need inputting to update the current value.
I’ve currently got the code:
Function update_db()
' need to update the database
Dim daoengine As DAO.DBEngine
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
daoengine = New DAO.DBEngine
dbs = daoengine.OpenDatabase("Project.mdb")
rst = dbs.OpenRecordset("ftsedata", DAO.RecordsetTypeEnum.dbOpenDynaset)
rst.Edit()
' what do I do here to edit the field "value" where ticker=UKX ?
rst.Close()
dbs.Close()
End Function
Public Sub getftsestock()
Dim sAPIUrl As String = "http://www.google.com/ig/api?stock=UKX"
Dim oDocument As XDocument = XDocument.Load(sAPIUrl)
Dim dLast As Double = CDbl(GetData(oDocument, "last"))
End Sub
First, change your sub into a function like so
Then do your update like this
However, it would be much more efficient to do this.