Each of these 4 examples produce the same result.
Example 1. Create recordset to string looping through each row and column.
Example 2. Create recordset to array
Example 3. Create recordset to string using compression and encryption.
Example 4. Create recordset to array using compression and encryption.
Comments: http://www.powerbasic.com/support/pb...ad.php?t=59295
Example 1. Create recordset to string looping through each row and column.
Example 2. Create recordset to array
Example 3. Create recordset to string using compression and encryption.
Example 4. Create recordset to array using compression and encryption.
Comments: http://www.powerbasic.com/support/pb...ad.php?t=59295
Code:
#INCLUDE "sqlitening.inc" FUNCTION PBMAIN () AS LONG LOCAL sData AS STRING, sArray() AS STRING LOCAL COL,rows AS LONG '-------------------------------------------------------------------------- 'slConnect "",0 'ip address and port for client/server slOpen "sample.db3","C" 'create if it does not exist slexe "drop table if exists simple" slexe "create table if not exists simple(c1,c2)" slexe "insert into simple values('hello','world!')" '-------------------------------------------------------------------------- '[COLOR=red]Example 1. Build recordset to string [/COLOR]slsel "select * from simple" rows = 0 sData = "" DO WHILE slgetRow INCR rows FOR COL = 1 TO slGetColumnCount sData += slf(COL) + "," NEXT ASC(sData,LEN(sData)) = 13 'last , to carriage return LOOP MSGBOX sData,,"Rows" + STR$(rows) '-------------------------------------------------------------------------- [COLOR=red]'Example 2. Build recordset to array [/COLOR]slSelAry("select * from simple",sArray(),"Q44 c") MSGBOX (JOIN$(sArray(),$CR)),,"Rows" + STR$(UBOUND(sArray)) '-------------------------------------------------------------------------- [B]'BOUND DATA EXAMPLES[/B] 'Insert text Compressed and Encrypted TCN parameters slexe "delete from simple" 'delete previous data in table slSetProcessMods "K" + STRING$(16,"A") 'encryption key 16,24 or 32 bytes slExeBind "insert into simple values(?,?)", _ slBuildBindDat("hello","TCN") + _ slBuildBindDat("world!","TCN") [COLOR=red]'Example 3. Build recordset to string Decrypted and Uncompressed[/COLOR] slsel "select * from simple" rows = 0 sData = "" DO WHILE slgetRow INCR rows FOR COL = 1 TO slGetColumnCount sData += slfx(COL,"DU") + "," 'decrypt uncompress NEXT ASC(sData,LEN(sData)) = 13 'last , to carriage return LOOP MSGBOX sData,,"Rows" + STR$(rows) '-------------------------------------------------------------------------- [COLOR=red]'Example 4. Build recordset to array Decrypted and Uncompressed [/COLOR]slSelAry("select * from simple",sArray(),"D1,2 U1,2 Q44 c") MSGBOX (JOIN$(sArray(),$CR)),,"Rows" + STR$(UBOUND(sArray)) END FUNCTION 'Notes: 'D1,2 = Decrypt columns 1,2 'U1,2 = Uncompress columns 1 and 2 'Q44 = delimit columns with a comma ASCII 44 'c = do not include column headings in recordset
Comment