Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 |
Public WinAPI Function TheFunctionName lib "thedllname" (ByVal ahandle As Integer) As Integer 'int sqlite3_open( 'Const char *filename, /* Database filename (UTF-8) */ 'sqlite3 **ppDb /* OUT: SQLite db handle */ '); Private WinApi Function sqlite3_open Lib "sqlite3"( _ ByVal filename As String, _ ByVal ppDb As Integer _ ) As Integer |
Hello OlimilO and thanks for your answer.
I haven't used sqlite3 with VB6 succesfully, but I do have use it succesfully with Rapid-Q and FreeBasic who also use stdcall (at least I think...).
I agree that using the callback function is rather difficult, so I don't use the sqlite_exec() function for SELECT queries. I use sqlite3_get_table() instead. I have also made a sort of "wrapper" dll in FreeBasic to acquire the result delimited data string from sqlite3_get_table(), as well as the number of rows and columns, without having to pass pointers as parameters. It works well with FreeBasic-compiled programs, but it fails to give the data string in Rapid-Q and VB6. In the latter cases I can only get the number of rows and columns. In Jabaco, I only get JRE error, concerning the sqlite3.dll module, not my own dll.
Greetings,
Frank
This post has been edited 1 times, last edit by "frankp" (Jan 29th 2009, 7:02pm)
Administrator
Date of registration: Jul 16th 2008
Location: Erlangen, Germany
Occupation: Software Developer
Hobbies: Jabaco, game theory, text-mining
Trainee
Date of registration: Jan 5th 2009
Location: Sesto Fiorentino, Florence (ITALY)
Occupation: design & development (HW, SW & FW)
Hobbies: chess, fly fishing, good wine and beautiful women!
Administrator
Date of registration: Jul 16th 2008
Location: Erlangen, Germany
Occupation: Software Developer
Hobbies: Jabaco, game theory, text-mining
Jabaco Source |
|
1 2 3 4 5 6 7 |
On Error Resume Next Dim database As New DataBase Dim driver As Class driver = Class.forName("SQLite.JDBCDriver") If driver = Nothing Then MsgBox "Not found!" On Error Goto 0 Call database.Connect("jdbc:sqlite:/:memory:") |
Trainee
Date of registration: Jan 5th 2009
Location: Sesto Fiorentino, Florence (ITALY)
Occupation: design & development (HW, SW & FW)
Hobbies: chess, fly fishing, good wine and beautiful women!
Trainee
Date of registration: Jan 5th 2009
Location: Sesto Fiorentino, Florence (ITALY)
Occupation: design & development (HW, SW & FW)
Hobbies: chess, fly fishing, good wine and beautiful women!
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Dim dbFile As String dbFile = App.Path & "/test.db" dbFile = Replace(dbFile, "", "/") Dim driver As Class driver = Class.forName("SQLite.JDBCDriver") If driver = Nothing Then MsgBox "SQLite Driver Not Found!" Exit Sub End If Dim database As New DataBase Dim rs As ResultSet Dim rsMetaData As java#sql#ResultSetMetaData database.Connect("jdbc:sqlite:/" & dbFile) rs = database.ExecuteStatement("SELECT * FROM country ORDER BY iso_code") rsMetaData = rs.getMetaData Dim ColumnName(1 To rsMetaData.getColumnCount) AS String Dim f As Integer For f = 1 To rsMetaData.getColumnCount ColumnName(f) = rsMetaData.getColumnName(f) Next f rs.close |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 |
rs = Database1.ExecuteStatement("SELECT * FROM Contacts") Do While res.next JBGrid1.TextMatrix(res.getRow() - 1, 0) = rs.getString("RecordId") JBGrid1.TextMatrix(res.getRow() - 1, 1) = rs.getString("Title") JBGrid1.TextMatrix(res.getRow() - 1, 2) = rs.getString("FirstNAME") JBGrid1.TextMatrix(res.getRow() - 1, 3) = rs.getString("MiddleName") JBGrid1.TextMatrix(res.getRow() - 1, 4) = rs.getString("LastName") rows = rows + 1 JBGrid1.Rows = rows Loop |
Administrator
Date of registration: Jul 16th 2008
Location: Erlangen, Germany
Occupation: Software Developer
Hobbies: Jabaco, game theory, text-mining
Nothing. Just "install" the driver by copying the files from the zip into your Java (JRE)-folder.Quoted
Do you know btw what should I include in Project/References?
I'll show you a better way in future. For now you could use this sample:Quoted
... the problem is that I do not know what methods and properties to fill a JBGrid with data from a Select!
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
On Error Goto ERROUT Dim driver As Class driver = Class.forName("SQLite.JDBCDriver") If driver = Nothing Then MsgBox "Not found!" Call database1.Connect("jdbc:sqlite:/:memory:") Call database1.ExecuteStatement("CREATE TABLE user (id Integer PRIMARY KEY, name varchar(10) NOT NULL, desc varchar(30) NOT NULL)") Call database1.ExecuteStatement("INSERT INTO user (id, name, desc) VALUES (1, 'manuel', 'developer')") Call database1.ExecuteStatement("INSERT INTO user (id, name, desc) VALUES (2, 'frankp', 'developer')") Call database1.ExecuteStatement("INSERT INTO user (id, name, desc) VALUES (3, 'maxim', 'developer')") Call database1.ExecuteStatement("INSERT INTO user (id, name, desc) VALUES (4, 'david', 'supporter')") Dim rsAllUsers As java#sql#ResultSet rsAllUsers = database1.ExecuteStatement("SELECT * FROM user") Dim i As Integer Dim rsAllUserColCount = rsAllUsers.getMetaData.getColumnCount JBGrid1.Cols = rsAllUserColCount For i = 1 To rsAllUserColCount JBGrid1.Header(i-1) = rsAllUsers.getMetaData.getColumnName(i) Next Do While rsAllUsers.next For i = 1 To rsAllUserColCount JBGrid1.TextMatrix(rsAllUsers.getRow() - 1, i - 1) = rsAllUsers.getString(i) Next rows = rows + 1 JBGrid1.Rows = rows Loop Exit Sub ERROUT: MsgBox Err.toString |
Beginner
Date of registration: May 29th 2010
Location: Santos, Brazil
Occupation: Consultant
Hobbies: Builing some apps for accessing databases and some automation processes
I downloaded the file (http://www.ch-werner.de/javasqlite/javas…81006-win32.zip) and have put the contents in the appropriate folders (Bin and in Java\Jre6\lib\ext), as described in other place, here in the forum.I'm too late but i won't trash my sample...Nothing. Just "install" the driver by copying the files from the zip into your Java (JRE)-folder.Quoted
Do you know btw what should I include in Project/References?I'll show you a better way in future. For now you could use this sample:Quoted
... the problem is that I do not know what methods and properties to fill a JBGrid with data from a Select!
Jabaco Source
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 On Error Goto ERROUT Dim driver As Class driver = Class.forName("SQLite.JDBCDriver") If driver = Nothing Then MsgBox "Not found!" Call database1.Connect("jdbc:sqlite:/:memory:") Call database1.ExecuteStatement("CREATE TABLE user (id Integer PRIMARY KEY, name varchar(10) NOT NULL, desc varchar(30) NOT NULL)") Call database1.ExecuteStatement("INSERT INTO user (id, name, desc) VALUES (1, 'manuel', 'developer')") Call database1.ExecuteStatement("INSERT INTO user (id, name, desc) VALUES (2, 'frankp', 'developer')") Call database1.ExecuteStatement("INSERT INTO user (id, name, desc) VALUES (3, 'maxim', 'developer')") Call database1.ExecuteStatement("INSERT INTO user (id, name, desc) VALUES (4, 'david', 'supporter')") Dim rsAllUsers As java#sql#ResultSet rsAllUsers = database1.ExecuteStatement("SELECT * FROM user") Dim i As Integer Dim rsAllUserColCount = rsAllUsers.getMetaData.getColumnCount JBGrid1.Cols = rsAllUserColCount For i = 1 To rsAllUserColCount JBGrid1.Header(i-1) = rsAllUsers.getMetaData.getColumnName(i) Next Do While rsAllUsers.next For i = 1 To rsAllUserColCount JBGrid1.TextMatrix(rsAllUsers.getRow() - 1, i - 1) = rsAllUsers.getString(i) Next rows = rows + 1 JBGrid1.Rows = rows Loop Exit Sub ERROUT: MsgBox Err.toString
Trainee
Date of registration: Jul 11th 2014
About me: A beginner programmer.
Location: ...Jabaco Academy
Occupation: i have some but still not enough...
Hobbies: Jabaco
Trainee
Date of registration: Jul 11th 2014
About me: A beginner programmer.
Location: ...Jabaco Academy
Occupation: i have some but still not enough...
Hobbies: Jabaco