I've found sqlite3.lib here: http://www.masmforum.com/simple/index.php?topic=1891.0  thanks to Hutch and MarkJones
and acces mdb example here: http://www.radasm.com/projects/Grid.zip  thanks to Ketil

Now i can write a simple app reading tables from mdb or sqlite database.
I read many docs about that but i ask your opinions (i'm a noob in database apps).

access mdb pros: popular fileformat, easy to use with odbc, some self-repair feature (redundant format?)
acces mdb cons:  no transactions (commit/rollback), nonfree acces runtime needed
sqlite pros: free, robust, transactions, odbc driver (in alpha stage)
sqlite cons: some missing SQL-92 functions

What will happens if database get corrupted, all data will lost?
Which is better, all tables in one file or split database into more files and attach them into one virtual database ? (sqlite3 can do that)

Here is my sample sqlite code (if someone need i will post more)

;
; Get column names to dest listview
;
SQLite3_GetColumns proc uses edi hStmt:DWORD,hDest:DWORD,lpColW:DWORD,iStart:DWORD
LOCAL nCol:DWORD
LOCAL lvc:LV_COLUMN

invoke sqlite3_step,hStmt
invoke SQLite3_CheckError
invoke sqlite3_column_count,hStmt
mov maxCol,eax
mov eax,iStart
mov nCol,eax
mov edi,lpColW
.while eax!=maxCol
invoke sqlite3_column_name,hStmt,nCol
mov lvc.imask,LVCF_TEXT+LVCF_WIDTH+LVCF_FMT
mov lvc.pszText,eax
mov eax,
mov lvc.lx,eax
add edi,4
mov lvc.fmt,LVCFMT_LEFT
invoke sqlite3_column_type,hStmt,nCol
invoke SendMessage,hDest, LVM_INSERTCOLUMN,nCol,addr lvc
inc nCol
mov eax,nCol
.endw
invoke sqlite3_reset,hStmt
invoke SQLite3_CheckError
ret
SQLite3_GetColumns endp

SQLite3_Get1RowLV proc uses ebx hStmt:DWORD,hDest:DWORD,iStart:DWORD
LOCAL lvi:LV_ITEM
LOCAL nCol:DWORD
mov eax,iStart
mov nCol,eax
.while eax!=maxCol
invoke sqlite3_column_text,hStmt,nCol
mov ebx,nCol
.if ebx==iStart
push eax
pop lvi.pszText
    mov lvi.imask, LVIF_TEXT
push ActRow
pop lvi.iItem
push ActRow
pop lvi.lParam
mov lvi.iSubItem,0
invoke SendMessage,hDest,LVM_INSERTITEM, 0,addr lvi
.else
push eax
pop lvi.pszText
push nCol
pop lvi.iSubItem
.if iStart==1
dec lvi.iSubItem
.endif
invoke SendMessage,hDest,LVM_SETITEM, 0,addr lvi
.endif
inc nCol
mov eax,nCol
.endw
inc ActRow
ret
SQLite3_Get1RowLV endp

SQLite3_GetAllRowLV proc hStmt:DWORD,hDest:DWORD,iStart:DWORD
mov ActRow,0
invoke sqlite3_step,hStmt
.while eax==SQLITE_ROW
invoke SQLite3_Get1RowLV,hStmt,hDest,iStart
invoke sqlite3_step,hStmt
.endw
push ActRow
pop maxRow
ret
SQLite3_GetAllRowLV endp

SQLite3_GetTableLV proc lpTable:DWORD,hDest:DWORD,lpColW:DWORD,iStart:DWORD
LOCAL buffer[256]:BYTE
LOCAL hStmt:DWORD
invoke lstrcpy,addr buffer,StrAddr ( "SELECT * FROM " )
invoke lstrcat,addr buffer,lpTable
invoke sqlite3_prepare,hDB,addr buffer,-1,addr hStmt,NULL
invoke SQLite3_CheckError
invoke SQLite3_GetColumns,hStmt,hDest,lpColW,iStart
invoke SQLite3_GetAllRowLV,hStmt,hDest,iStart
invoke sqlite3_reset,hStmt
invoke SQLite3_CheckError
invoke sqlite3_finalize,hStmt
invoke SQLite3_CheckError
mov eax,hDest
mov lvsort.handle,eax
mov lvsort.direction,FALSE ; false = forward/ true = rev
mov lvsort.column,0
mov lvsort.stype,1 ; 1 = text
invoke SendMessage, hDest, LVM_SORTITEMSEX, addr lvsort, addr LVSortProc
ret
SQLite3_GetTableLV endp


Posted on 2005-12-10 13:46:31 by s5vi
Hi, could you please attach the sqlite3.lib for masm here, the masmforum seems not accessable. I really need this, thanks in advance.
Posted on 2006-01-12 04:13:53 by bisj
Here you are!
Attachments:
Posted on 2006-01-16 06:05:16 by s5vi
Hi!

I'm also interested about sqlite database programming, in Masm. I've used sqlite in other aspects. But unfortunately the download also inaccessible here. Could you put it on a http, or ftp site?

10x
SoftMan
Posted on 2006-03-18 02:24:46 by SoftMan

What will happens if database get corrupted, all data will lost?

Good question!

Might be worth asking this on the sqlite mailing list. I'd *guess* it has error recovery since sqlite has been built for stability (ACID etc.)

IIRC it's also in use by the US army, if that counts for anything.


Which is better, all tables in one file or split database into more files and attach them into one virtual database ?

Also a good question - I guess the multi-file approach is a bit more resistant to corruption, and probably has faster "drop table" speed.
Posted on 2006-03-18 11:43:57 by f0dder