Advice on storing properties
    erne 
    ernestogiannotta at tiscalinet.it
       
    Sat Aug 23 23:26:12 CDT 2003
    
    
  
Hi Jem,
On Domenica, ago 24, 2003, at 10:58 Europe/Rome, Jan Erik Moström wrote:
> I want to design a database that contains some unique settings for each
> database. I would like to store this information together with the
> database in a single file but I'm unsure of what is the best way of
> doing it. I could make a new table and store the information there ...
> but it seems a bit wasteful (only one single information piece with a
> lot of different kind of data in in, text as well as different binary
> information).
>
> I might be missing something but I couldn't find a way of making a
> "global variable" where I could store this information. So, does anyone
> have any advice on how to do this?
>
I usually set a prefs table like this:
   //  Internal name for Multilanguage compatibility
   Name = "Prefs"
   // Type holder
   PrefType = new VString("Type", 15, "ASCII")
   // Name holder
   PrefName = new VString("Name", 25, "ASCII")
   // to store strings
   PrefString = new VVarChar("String", 500, "ASCII")
   // to store integers
   PrefInteger = new VLong("Integer")
   // to store booleans
   PrefBoolean = new VBoolean("Bool")
   // to store dates
   PrefDate = new VDateTime("Date")
   // to store pictures
   PrefPict = new VPicture("Pict", 1024)
and some functions like these:
Function GetPrefType(theType as String, theName as String) As VCursor
    dim SqlString as String
    dim c as VCursor
    dim res as boolean
    SqlString = "Select * From " + me.Name
    SqlString = SqlString + " Where " + me.PrefType.Name + " = '" + 
theType + "'"
    SqlString = SqlString + " And " + me.PrefName.Name + " = '" + 
theName + "'"
    c = me.DataBase.SQLselect(SqlString, kV_Client, kV_NoLocks, 
kV_Random)
    if c <> nil then
       if c.RecordCount = 0 then
          // preferences missing
          c.SetBlank
          c.Field(me.PrefType.Name).SetString theType
          c.Field(me.PrefName.Name).SetString theName
          res = c.Add
       end if
    end if
    Return c
HTH
Cool Runnings,
Erne.
End Function
|er| musical box
|ne| a media store
    
    
More information about the Valentina
mailing list