Sqlite version returning blank

Hello

Using your documented code I can create a “students.db” database. It returns “created DB - ok”.

When i run the program for the second time the DB.version is returning blank. This means it tries to create it for the second time but of course this fails.

I am using latest App studio version and tried on chrome and android both same result.

any ideas?

many thanks
Malc

Dim DB

Sub Main
  
  If window.openDatabase Then
    'SQLite can be used.
    alert("SQlite can be used")
  Else
    alert("SQlite cannot be used")
    'SQLite is not supported
  End If
  
  DB = SqlOpenDatabase("students.db")
  If DB.version <> "" Then
    alert ("Database version is " & DB.version)
  Else
    sqlList=[]
    sqlList[0]=["CREATE TABLE studentData('name', 'age', PRIMARY KEY('name') );", success, fail]
    Sql(DB, sqlList)
  End If

End Sub

Sub success()
  alert("created DB - ok")
End Sub

Sub fail()
  alert("created DB - failed")
End Sub

What browser are you using? On the desktop or a device?

SqlOpenDatabase() calls window.openDatabase(), which is a function in Chrome. It’s tough to find current documentation for that call. It’s possible it has changed since that page in our Wiki was written in 2010.