[Resolved] SQLite Database not updating

I have been having trouble with a class we used some time ago on older builds of corona to help with our sqlite database, and recently I have come across some very odd behavior from it. Basically this method I am listing and a few others are not updating in the database.

[code]module(…, package.seeall)

require “sqlite3”
function getReferenceToDB()

– See if Database File Already Exists in Documents Directory
path = system.pathForFile( “mndb.sqlite”, system.DocumentsDirectory )
file = io.open( path, “r” )

if( file == nil )then

– Doesn’t Already Exist, So Copy it In From Resource Directory

pathSource = system.pathForFile(“chdb.sqlite”, system.ResourceDirectory)
fileSource = io.open( pathSource, “r” )
contentsSource = fileSource:read( “*a” )

– Write Destination File in Documents Directory

pathDest = system.pathForFile( “chdb.sqlite”, system.DocumentsDirectory )
fileDest = io.open( pathDest, “w” )
fileDest:write( contentsSource )

– Done

io.close( fileSource )
io.close( fileDest )

end

– One Way or Another The Database File Exists Now
– So Open Database Connection
local path = system.pathForFile(“chdb.sqlite”, system.DocumentsDirectory)

– open db
db = sqlite3.open( path )
end

function setCurrentView(theString)
getReferenceToDB()
local sql = “UPDATE userdata SET currentview = '”…theString…"’"
db:exec(sql)
db:close()
end
[/code]

This is a snip-it of the code we are using, if anyone has any answers or suggestions as to why it isn’t updating the DB it would greatly be appreciated. [import]uid: 39480 topic_id: 32565 reply_id: 332565[/import]

Why are you testing for mndb.sqlite but later opening chdb.sqlite? This will cause the system to copy the database from the resource directory every time you call setCurrentView. [import]uid: 19626 topic_id: 32565 reply_id: 129461[/import]

Thank you very much. Sometimes is the simplest things that cause the greatest headaches. [import]uid: 39480 topic_id: 32565 reply_id: 129472[/import]

Why are you testing for mndb.sqlite but later opening chdb.sqlite? This will cause the system to copy the database from the resource directory every time you call setCurrentView. [import]uid: 19626 topic_id: 32565 reply_id: 129461[/import]

Thank you very much. Sometimes is the simplest things that cause the greatest headaches. [import]uid: 39480 topic_id: 32565 reply_id: 129472[/import]