I have used REALBasic for a while and was pretty fluent in getting things done. Well I took a break from coding came back and found that XOJO had replace REALBasic and am now starting back into coding. Well, using my old methods of connecting to an SQLite DB… they don’t seem to work. So here is how I have been doing things:
Module.Method.mthDbConn
[code] // Variable Declarations
Dim fldItm As FolderItem = GetFolderItem("")
// Preliminary Functions…
’ :-- NONE DEFINED --:
// Primary Functional Logic… #If DebugBuild Then fldItm = fldItm.Parent
Return fldItm[/code]
App.Open
[code] // Variable Declarations
Dim dbFldrItm As FolderItem = modConn.[i]mthDbConn/i
Dim dbaKdg As New SQLiteDatabase
// Preliminary Functions…
dbaKdg = New SQLiteDatabase ’ Instantiate a new instance
dbFldrItm = dbFldrItm.Child(“DB”).Child(“dbKdg.rsd”) ’ Define the location and load the variable
// Primary Functional Logic…
// Test to ensure the folder and database actually exist.
If(dbFldrItm) <> Nil Then
If(dbFldrItm.Exists) Then
dbaKdg = dbFldrItm
Else
MsgBox "Database isn't there." + EndOfLine + Str(dbaKdg.ErrorCode) + EndOfLine + dbaKdg.ErrorMessage
Return
End If
Else
MsgBox “The folder containing the database isn’t there!” + EndOfLine + “Error is located in: App.Open”
Return
End If[/code]
In App.Open I am getting a Type mismatch error. What has changed that this code no longer works? Oh… and I can’t seem to find a search function in the forum either…
But note that once you’re in a conversation, you can only search within that conversation (that’s what the cue text says). Go back to the main forum page to search everything.
Okay… well I have it kind of connecting… it makes it through the App.Open phase but when I try to select a recordset it pukes.
` // Variable Declarations
Dim rcSet As RecordSet
// Preliminary Functions…
’ :-- NONE DEFINED --:
// Primary Functional Logic…
If(dbKdg.Connect) = True Then
If(stClid) = “” Then
rcSet = dbKdg.SQLSelect(“SELECT * FROM tblCliLst ORDER BY clId”)
ElseIf(stClid) = "FN" Then
rcSet = dbKdg.SQLSelect("SELECT * FROM tblCliLst WHERE fNme ='" + stNme + "' ORDER BY clId")
ElseIf(stClid) = "LN" Then
rcSet = dbKdg.SQLSelect("SELECT * FROM tblCliLst WHERE lNme ='" + stNme + "' ORDER BY clId")
Else
'rcSet = dbKdg.SQLSelect("SELECT * FROM tblCliLst WHERE lNme ='" + stNme + "' ORDER BY clId")
End If
Else
If(dbKdg.Error) Then
’ Test to see if the Database has issues…
Beep
MsgBox "Database Error: " + Str(dbKdg.ErrorCode) + EndOfLine.Windows + EndOfLine.Windows _
+ dbKdg.ErrorMessage + EndOfLine.Windows + EndOfLine.Windows _
+ “Error thrown from modSel.mthCli”
Exit
End If
MsgBox "Database isn't connecting! The error code is :" + Str(dbKdg.ErrorCode) + EndOfLine.Windows _
+ dbKdg.ErrorMessage + EndOfLine.Windows + EndOfLine.Windows _
+ "Error thrown from modSel.mthCli"
Exit
End If`
This is the error that is being thrown…
MsgBox "Database isn't connecting! The error code is :" + Str(dbKdg.ErrorCode) + EndOfLine.Windows _
+ dbKdg.ErrorMessage + EndOfLine.Windows + EndOfLine.Windows _
+ "Error thrown from modSel.mthCli"
Exit
Maybe a small project i recently startet on GitHub, can give you some insight in Xojo+SQLite.
It’s a project for some kind of Help System for Xojo Apps, which uses a local SQLite Database.
The App creates a new SQLite Database upon App start if it’s not already there and then opens the Database to read and store rows.
Ian, if the various code segments you have in this thread are still intact, you may have no connection to the database. I can’t see the entire set of code, but it looks like you Dim the database variable DbKdg as a SQLiteDatabase in the App.Open event. Doing that means that it is local to the App.Open event. If the code to Connect isn’t in the App.Open event the database isn’t available and the Connect will fail.
So, if you haven’t done so, move the declaration of the database to a global variable and remove the ‘Dim’ from the statement in the App.Open event.