Powerbuilder – Connect to SQLite version 3 database (ODBC)

Posted on Tuesday, June 14th, 2011 at 8:20 pm in

If you are interested in doing Powerbuilder development with an SQLite database here is the DSN Less connection string to get you going.

string ls_dbparm, ls_dbfile, ls_exepath, ls_file[]

ls_dbfile = c:\temp\sqlite.db3'

IF Fileexists(ls_dbfile) THEN
	// do nothing
ELSE
	IF GetFileOpenName('Select Data File',ls_dbfile, ls_file,'db3','SQLite files (*.db3),*.db3') < 1 THEN
		Messagebox('No Data File Chosen','Application will close')
		HALT CLOSE
	END IF
END IF
// SQLite connection
ls_dbparm = "ConnectString='"
// Driver installed with SQLite2009 Pro Enterprise Manager
ls_dbparm = ls_dbparm + "DRIVER=SQLite2010 Pro ODBC Driver;" 
ls_dbparm = ls_dbparm + "Database=" + ls_dbfile + "'" 
ls_dbparm = ls_dbparm + "UID=" + "admin" + ";PWD="
ls_dbparm = ls_dbparm +  "'" 
sqlca.DbParm=ls_dbparm 

sqlca.DBMS = "ODBC"

CONNECT USING SQLCA;
IF (sqlca.sqlcode) <> 0 THEN 
	MessageBox("Database Log On Error","Failed to Connect to Database" +string(sqlca.sqlcode)+" "+sqlca.DBparm  + sqlca.sqlerrtext)
  	HALT CLOSE
END IF

You can download the database and a pretty good manager application here:
SQLite2009 Pro Enterprise Manager (FREE)

Yes, yes, I know there are other tools which may ‘kick SQLite to the curb’ but that’s up to you to decide.

Add your comment

Leave a Reply

Top