Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private taula As Cursor
Private dbSql As SQL
End Sub
Sub Activity_Create(FirstTime As Boolean)
If File.Exists(File.DirInternal,"Lcuras.sql")=True Then ' Necesitas tener una base de datos con este nombre
dbSql.Initialize( File.DirInternal,"Lcuras.sql",False)
Else
Msgbox("No se encuentra la base de datos","Atencion")
Activity.Finish
End If
ComprobarBaseDatos
End Sub
Sub ComprobarBaseDatos
Dim i As Int
Dim ssql As String
Dim trobat As Boolean
trobat=False
taula = dbSql.ExecQuery("SELECT name FROM sqlite_master WHERE Type='table'")
For i = 0 To taula.RowCount - 1
taula.Position=i
If taula.GetString("name")="Pacientes" Then trobat=True
Next
If trobat=False Then
ssql= "CREATE TABLE Pacientes (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , historial VARCHAR(30) , nombre VARCHAR(100))"
dbSql.ExecNonQuery(ssql)
Msgbox("La base de datos se ha creado","Atención")
End If
End Sub