This is sort of related to my last question. I want to make a "Settings"
folder in the same locale as the application - if it doesn't exist create, if
it
does exist, then put files into it. I'm a little confused as to the
create/connection distinction in this case. Similarly, with databases .... I
read the
examples for creating a new database or opening an existing one. However, how
can
you open it if it exists, create it if it does not exist? Here is my attempt
:
//____ Dim______________
Dim dbFile as FolderItem
Dim db as REALdatabase
//____ Setup______________
db = New REALdatabase
dbFile = GetFolderItem("DB File")
db.DatabaseFile=dbFile
//____ Consolidated Connect/Create - 1st attempt _____________
If db.Connect() then //DB Opened ... proceed with operations
//XX do stuff here
else //Database NOT oened ... try to create
If db.CreateDatabaseFile then //DB created, proceed
//XX do stuff here
else
MsgBox "Database not found and not created"
end if
end if
//...note the need to do the same stuff twice (upon succesful opening or
succesful creation)
//...and its not clear to me if you can do record inserts into the DB from
a routine (method)
//...- this would make it easier to modularize that operation, but how do
you pass the db references?
//____ Consolidated Connect/Create - 2nd attempt _____________
If not( db.Connect() then //DB Opened ... proceed with operations
if not( db.CreateDatabaseFile) then
MsgBox "Database not found and not created"
return
end if
end if
//do DB stuff here for both cases (connected to existing, or just
created) - knowing that you
// can't get here in bad cases (not created or not connected) -
however this leaves me feeling
// like there might be some case where the control can somehow
sneak into this part of code
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|