
In the example DatabaseQuery() is shown and not DatabaseUpdate()
The last example shows DatabaseUpdate() and this is done without FinishDatabaseQuery()
There is no FinishDatabaseUpdate().
All in all: the help for DatabaseUpdate() should be modified.
Code: Select all
If UseSQLiteDatabase("myExternal.DLL")
UseSQLiteDatabase() has no return value. See https://www.purebasic.com/documentation ... abase.html.jassing wrote: Mon Aug 07, 2023 11:22 pm Another thing no one pointed out, is when using an external dll - you should do:
Code: Select all
If UseSQLiteDatabase("myExternal.DLL")
Why did you create a new Topic bug ? As for Infratec (Thanks for libcrypto-1_1-x64.dll), it works here too:
Code: Select all
; sqlcipher_demo.pb
; It needs sqlcipher.dll and libcrypto-1_1-x64.dll downloaded/extracted from https://download.sqlitebrowser.org/DB.Browser.for.SQLite-3.12.2-win64.zip
; - both dll next to exe directory
; - or next to sqlcipher_demo.pb in Debug mode with Compil/Run (F5)
; In Debug, better to have CompileSourceDirectory compiler option enabled
EnableExplicit
Define.i FileExitsAlready
Define Filename$, Result$
UseSQLiteDatabase("sqlcipher.dll")
Debug "CurrentDirectory: " + GetCurrentDirectory()
Debug "sqlcipher.dll size: " + Str(FileSize("sqlcipher.dll"))
Debug "libcrypto-1_1-x64.dll size: " + Str(FileSize("libcrypto-1_1-x64.dll"))
Filename$ = GetPathPart(ProgramFilename()) + GetFilePart(ProgramFilename(), #PB_FileSystem_NoExtension) + ".sqlite"
If FileSize(Filename$) = -1
If CreateFile(0, Filename$)
CloseFile(0)
EndIf
Debug "File: " + Filename$ + " Created"
Else
Debug "File: " + Filename$ + " Already Exist"
FileExitsAlready = #True
EndIf
If OpenDatabase(0, Filename$, "", "")
Debug "OpenDatabase OK"
If DatabaseUpdate(0, "PRAGMA key = 'passkey';")
Debug "DatabaseUpdate Set Key OK"
If Not FileExitsAlready
If DatabaseUpdate(0,"CREATE TABLE test (field1 INTEGER,field2 INTEGER);")
Debug "DatabaseUpdate Create Table OK"
If DatabaseUpdate(0,"INSERT INTO test (field1,field2) VALUES (1,1),(2,2),(3,3);")
Debug "DatabaseUpdate Insert Data OK"
Else
Debug "DatabaseUpdate Insert Data Error: " + DatabaseError()
EndIf
Else
Debug "DatabaseUpdate Create Table Error: " + DatabaseError()
EndIf
EndIf
If DatabaseQuery(0,"SELECT field1, field2 FROM test;")
Debug "DatabaseQuery OK"
While NextDatabaseRow(0)
Result$ + GetDatabaseString(0, 0) + " , " + GetDatabaseString(0, 1) + #LF$
Wend
FinishDatabaseQuery(0)
Debug "*** DatabaseQuery Result ***" + #CRLF$ + Result$
Else
Debug "DatabaseQuery Error: " + DatabaseError()
EndIf
Else
Debug "DatabaseUpdate Set Key Error: " + DatabaseError()
EndIf
CloseDatabase(0)
Else
Debug "OpenDatabase Error: " + DatabaseError()
EndIf
; IDE Options = PureBasic 6.02 LTS (Windows - x64)
; Compiler = PureBasic 6.02 LTS (Windows - x64)
; EnableXP
; Executable = sqlcipher_demo.exe
; CompileSourceDirectory
In a feature request, wouldn't it be good to have a return value and a DatabaseError(), it would help here ?Kiffi wrote: Tue Aug 08, 2023 12:07 am UseSQLiteDatabase("myExternal.DLL") has no return value. See https://www.purebasic.com/documentation ... abase.html.