SQLite

BlitzMax Forums/BlitzMax Programming/SQLite

MacSven(Posted 2012) [#1]
I have a database. The sample from the module shows me the main entry's.



Import BaH.DBSQLite
Import BRL.filesystem

Local db:TDBConnection = LoadDatabase("SQLITE", "lavrc.db")

If Not db Then
	DebugLog("Didn't work...")
	End
End If

If db.hasError() Then
	errorAndClose(db)
End If


If db.isOpen() Then

	' get a list of tables in the database
	Local list:String[] = db.getTables()
	If list Then
		For Local i:Int = 0 Until list.length
			Print"   " + (i + 1) + ".   " + list[i]
		Next
	End If

	db.close()
	
End If

Function errorAndClose(db:TDBConnection)
	Print db.error().toString()
	db.close()
	End
End Function



How can i access the entry's of each main entry?

Has anybody an sample!


Rixarn(Posted 2012) [#2]
You want to do a query in the database? if so, this is how you do it..

[bbcode]

Local query:TDatabaseQuery = TDatabaseQuery.Create(db)
Local q:String = "SELECT * FROM YourTableName"
query.execute(q)
While query.nextRow()
Local record:TQueryRecord = query.rowRecord()
Local id:Int = record.value(0).getInt()
Local firstName:String = record.value(1).getString()
Local LastName:String = record.value(2).getString()
'etc...
Wend
[/bbcode]

Last edited 2012


MacSven(Posted 2012) [#3]
Thanx, that works!