sqlite database confusion

First, I’m on Xojo 2017r3. I’m following the instructions here to set up a simple 1-table database to store information from a dictionary. This tutorial was clearly made with a different version of the IDE, but I was able to figure it out and make the database. I see it in the left column of the IDE. Note that I don’t care if this database is persistent - it’s meant to be a temporary place to compile the records before exporting a report. It’d be fine as an in-memory database (which is what I’ve just set up, right?)

I have a Module with a single property: db as database so that it’s global.

In my App, I have an Open Event Handler that opens the database, ManifestReports:

db = ManifestReports if db = Nil then MsgBox "Manifest Report DB not found" end if

This works - or at least, it doesn’t fail.

My app traverses a folder and gathers metadata about the files it contains, putting each file’s metadata into a dictionary (mediaItem) . When that’s done, it’s supposed to add a row to the database, one for each file:

[code]dim r as DatabaseRecord
r = new DatabaseRecord

//loop through the dictionary that holds the metadata for this file
//and set it up to be added to the database
for each key As Variant In mediaItem.Keys
dim field as string = key
r.column(field) = mediaItem.value(key)
next

//connect to and add the metadata to the database
If db.Connect Then
db.InsertRecord(“mediaInfo”, r)
else
msgBox db.errormessage
end if

//display any errors
if db.error then
msgBox db.errormessage
end if
[/code]

However, it’s never connecting to the database. The error message it’s giving is that there is no error message, but db.Connect is somehow failing.

Am I missing something fundamental here?

Shouldn’t that be db As SQLiteDatabase (or any other)?

You might wanna try the “examples” instead of old documentation, they will show you how it’s done instead of how to do it.

Hmm. When I change the property to db as SQLiteDatabase, I get the following error in my App’s Open event handler:

App.Open, line 16 Type mismatch error. Expected class SQLiteDatabase, but got class Database db = ManifestReportsDB

Has that tutorial sent me barking up the wrong (outdated) tree?

The Connecting to Databases video might be helpful:

https://youtu.be/Cshtk7VmEqw

[quote=425364:@Perry Paolantonio]Hmm. When I change the property to db as SQLiteDatabase, I get the following error in my App’s Open event handler:

App.Open, line 16 Type mismatch error. Expected class SQLiteDatabase, but got class Database db = ManifestReportsDB

Has that tutorial sent me barking up the wrong (outdated) tree?[/quote]

In app.open do db = New SqliteDatabase tomake an instance of the “db” property

Perry:

Part of the link to the project is:
ReallyBasicRB/Sits/SimpleDB.sit

This (IMHO) an old (very old) project. The sit extension (StuffIt) dates from the early 200x…

This is the complete link: “file:///ReallyBasicRB/Sits/SimpleDB.sit” and is not currently downloadable.

My conclusion: Kill that project and forget all about it,

Advice:
Create a brand new Project,
Take the current language reference code examples,
Put these together,
And you will get a fully worked db example (with a bit of work).

Using a totally outdated project with a recent (2 years old) IDE is a really bad idea.

I got it working this morning. Thanks everyone