Theos PowerBasic Museum 2017

Archive => Archived Posts => Topic started by: José Roca on June 01, 2011, 12:31:06 AM

Title: SQLite v. 3.7.6.3 Headers
Post by: José Roca on June 01, 2011, 12:31:06 AM
 
About SQLite

SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine. Features include:


The SQLite distribution comes with a standalone command-line access program (sqlite) that can be used to administer an SQLite database and which serves as an example of how to use the SQLite library.

SQLite website: http://www.sqlite.org/

The attached file contains my translation of the SQLite headers to PowerBASIC.
Title: SQLite v. 3.7.6.3 Example: Creating a database
Post by: José Roca on June 01, 2011, 12:31:54 AM
 
The following example demonstrates how to create a database using SQLite.


' ########################################################################################
' Sqlite example
' Creates a dabase.
' ########################################################################################

' SED_PBCC
#COMPILE EXE
#DIM ALL
#INCLUDE "WINDOWS.INC"
#INCLUDE "SQLITE3.INC"

$TEST_DATABASE = "TESTDB.SQLITE"

' ========================================================================================
' Returns an string describing in English the error condition for the most recent
' sqlite3_* API call.
' ========================================================================================
FUNCTION SQL3_ErrMsg (BYVAL hSqlite AS DWORD) AS STRING
   LOCAL pErrMsg AS ASCIIZ PTR
   IF hSqlite = %NULL THEN EXIT FUNCTION
   pErrMsg = sqlite3_errmsg(hSqlite)
   FUNCTION = @pErrMsg
END FUNCTION
' ========================================================================================

' ========================================================================================
' Main
' ========================================================================================
FUNCTION PBMAIN () AS LONG

   LOCAL hr AS LONG
   LOCAL hLite AS DWORD
   LOCAL szDbName AS ASCIIZ * %MAX_PATH
   LOCAL szSQL AS ASCIIZ * 256
   LOCAL pTable AS DWORD PTR
   LOCAL cRows AS LONG
   LOCAL cCols AS LONG
   LOCAL pErrMsg AS ASCIIZ PTR

   ' Delete the database if already exists
   szDbName = $TEST_DATABASE
IF DIR$(szDbName) <> "" THEN
KILL szDbName
END IF

   ' Create the database
   hr = sqlite3_open(szDbName, hLite)
   IF hr <> %SQLITE_OK OR hLite = %NULL THEN
      PRINT "Error " & STR$(hr) & " creating the database"
      IF hLite THEN sqlite3_close(hLite)
      EXIT FUNCTION
   END IF

' Create a table
   szSQL = "CREATE TABLE Table1 (ID INT, Name TEXT, Age TEXT)"
   hr = sqlite3_get_table(hLite, szSQL, pTable, cRows, cCols, pErrMsg)
   IF hr <> %SQLITE_OK THEN
      PRINT @pErrMsg
      sqlite3_free(pErrMsg)
      GOTO Terminate
   END IF

   ' Discard the result set
   if pTable THEN sqlite3_free_table (pTable)

   PRINT "Database created"

Terminate:

   ' Close the database
   IF hLite THEN sqlite3_close(hLite)

   WAITKEY$

END FUNCTION
' ========================================================================================

Title: Re: SQLite v. 3.7.6.3 Headers
Post by: Robert Sarrazin on November 10, 2011, 10:33:19 PM
SQLite v. 3.7.6.3 Headers
« on: June 01, 2011, 12:31:06 AM »

* SQLite_3_7_6_3.rar (388.97 kB - downloaded 40 times.)
« Last Edit: August 06, 2011, 02:34:10 PM by José Roca »

I got index.php  8)
I can't download SQLite_3_7_6_3.rar :'(
Title: Re: SQLite v. 3.7.6.3 Headers
Post by: José Roca on November 10, 2011, 11:12:02 PM
Works fine with FireFox 7.1 and Internet Explorer 9. Which browser and version are you using?
Title: Re: SQLite v. 3.7.6.3 Headers
Post by: José Roca on November 10, 2011, 11:30:48 PM
It is a problem with FireFox 8.0. See: http://www.simplemachines.org/community/index.php?topic=458550.msg3203556#msg3203556

Try right-click>"Save link as" to see if it works.
Title: Re: SQLite v. 3.7.6.3 Headers
Post by: Edwin Knoppert on November 11, 2011, 07:00:37 PM
I was aware of the filename issue since a while, about two years ago i had a similar thing, some browsers don't accept the quotes at all.
I forgot which browser then but it may have been FF all along..
The problems appeared with our own download (file) streams assembly (ASP.NET).

I believe the solution was to abandon the quotes, even if a name having spaces is involved.

(For you to find out :) )