今天要使用powerbuilder 读取医保日志 ,于是写了一个database.dll文件,用于访问sqlite3数据库。
database.dll这个文件使用万能vc++2005编绎,源码:www.sqlite.org中下载3.8.10版本
为了方便pb的使用,将sqlite*指针转化为long类型。
以下是导出的函数声明
function int sqlite3open_v2(string filename,ref long ppDb,int flags,string zVfs) library "database.dll" function int sqlite3open(string filename,ref long ppDb ) library "database.dll" function int sqlite3close_v2(long ppDb) library "database.dll" function int sqlite3close(long ppDb) library "database.dll" function int sqlite3open16(string filename,ref long db) library "database.dll" function int sqlite3exec(long db,string sql) library "database.dll" function string sqlite3errmsg16(long db) library "database.dll" function string sqlite3errmsg(long db) library "database.dll" function int sqlite3prepare16(long db,string sql,ref long pStmt) library "database.dll" function int sqlite3prepare(long db,ref long pStmt) library "database.dll" function int sqlite3step(long pStmt) library "database.dll" function int sqlite3finalize(long pStmt) library "database.dll" function string sqlite3column_text16(long pStmt,int iCol) library "database.dll" function string sqlite3column_text(long pStmt,int iCol) library "database.dll" function string sqlite3column_name16(long pStmt,int iCol) library "database.dll" function string sqlite3column_name(long pStmt,int iCol) library "database.dll" function longlong sqlite3last_insert_rowid(long db) library "database.dll" function int sqlite3changes(long db) library "database.dll" function int sqlite3data_count(long db) library "database.dll" function long UTF8ToAnsiString(string lpstring,ref string buff,long nBufflen ) library "database.dll"
示例代码
long ret,db,record string value ; ret = sqlite3open ("e:\\test.db",db) if(db=0) then end if parent.title = string(db) ret = sqlite3prepare(db,"Select * From table where xh > 1 ",record) do while(sqlite3step(record) =100) value = sqlite3column_text(record,5) loop string Fieldname; int iDataCount =0 ; iDataCount = sqlite3data_count(record) sqlite3finalize(record); sqlite3close (db)
原文链接:https://www.f2er.com/sqlite/199453.html