I know I am doing something stupid here, but I can’t figure it out
I have a recordset that is populated from a prepared sql statement.
I then attempt to set one of the fields to another value and update the database, but the field is not being updated. in debugging it looks like the updated field value is not being set in the recordset.
passedValue is a string variable passed into this method:
1st msgbox shows “ZAnder” (“ZAnder” is what was pulled from the DB)
2nd msgbox shows “asd” (“asd” is what was passed into the method)
3rd msgbox shows “ZAnder”
I was expecting rs.field(“lastName”).value to be “asd”
Here is the whole method. Maybe there is something else in here that is messing it up…
I understand I may not be doing this in the most efficient way, but functionally I am expecting this method to update multiple rows in a database based on the contents of a listbox where the “entryId” field is the 1st column of the listbox passed in:
parameters to the method are as follows:
lb as Listbox passedField as String (value passed into the method during test is “lastName”) passedValue as string (value passed into the method during test is “asd”)
Dim stmt As PreparedSQLStatement = Self.Prepare("SELECT entryID, lastName, firstName, MaidenName, page from entries where entryID = ?")
Dim i as Integer
dim rs as RecordSet
for i=0 to lb.LastIndex
stmt.BindType(0, SQLitePreparedStatement.SQLITE_INTEGER)
stmt.Bind(0, lb.Cell(i,0))
rs = stmt.SQLSelect
if rs <> Nil then
if passedField="lastName" then
msgbox(rs.field("lastName").stringvalue)
msgbox (passedValue)
rs.field("lastName").stringvalue = passedValue
msgbox(rs.field("lastName").stringvalue)
rs.update
end if
else
msgbox(str(Self.ErrorCode) + ": " +Self.ErrorMessage)
end if
next
rs.close
Return Not Self.Error