I have a desktop app. On first run it checks for a database, if not found, it creates one (REALSQLDatabase) Then creates a table called DBConnect, then adds a record set with host, user, pass and name for connecting to a postgre database on the net (in this example code and for testing it is just going to a localhost). It populates the database with default settings.
In Open Event of App:
PawnLocalDB = New REALSQLDatabase
PawnLocalDB.databaseFile = GetFolderItem(“Pawn.rsd”)
if PawnLocalDB.databaseFile.exists = true then
if PawnLocalDB.Connect() = false then
DisplayDatabaseError( false )// there was an error connecting to the database
In Method CreateDatabaseFile:
if PawnLocalDB.CreateDatabaseFile = false then
MsgBox “Database Error” + EndOfLine + EndOfLine + “There was an error when creating the database.”
PawnLocalDB.SQLExecute “create table DBConnect (DBHost varchar, DBUser varchar, DBPass varchar, DBName varchar, DBNum integer NOT NULL PRIMARY KEY)”
dim rec as DatabaseRecord
rec = New DatabaseRecord
rec.Column(“DBHost”) = “localhost”
rec.Column(“DBUser”) = “Avro”
rec.Column(“DBPass”) = “”
rec.Column(“DBName”) = “Avro”
PawnLocalDB.InsertRecord “DBConnect”, rec
First run, it create the local REALSQLDatabase, apparently create the table called DBConnect and populates it with the default record set, because in the next part of the app, it gathers the data from that table and connects to the POSTGREDatabase. Connection is successful.
Second run, it sees the local REALSQLDatabase is there, connects to it, but returns an error stating, table DBConnect does not exist?
dim rs As RecordSet
rs = PawnLocalDB.SQLSelect(“SELECT * FROM DBConnect”)
if PawnLocalDB.error = true then