Results 1 to 9 of 9

Thread: Database or Registry?

  1. #1
    Stiletto
    Guest

    Database or Registry?

    Sups,
    I got this declarations:
    VB Code:
    1. Public Type CityType
    2.     Name as String
    3.     PName as String
    4.     HPay as Integer
    5.     Hotel as Integer
    6. End Type
    7. Dim Cities[1 to 15] as CityType
    I need to save all of this data, all 15 cities.
    My question is, where should i save it, on a database (I dont wanna use SQL, h8 it! ), or on registry.
    That's alot of data, and if on registry, i wanna know how to remove it when uninstalling the app, so wacha think?

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I would suggest saving it to a file and then encrypting it if you don't want anybody else to see it.
    Registry is mostly used to store a small number of properties for your application.
    Baaaaaaaaah

  3. #3
    Stiletto
    Guest
    I was thinkin about this way, but its alot of data, plus i got, lets say, something like 3 users playin, which is 15*3 cities...

  4. #4
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    It'll take almost same space as the registry and also it's gonna be pretty messy in the registery saving a lot of stuff. So you can either use a database file (eg .mdb) or simple ascii file as I said above.
    Baaaaaaaaah

  5. #5
    Stiletto
    Guest
    K. Is there a way to remove the data from the registry?

  6. #6
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482

    Re: Database or Registry?

    Hi Stiletto,
    Well..why u r not using ACESS 2000 as backend? Any problems?
    Well..i don't know much about registry..but i think u can store this data in one single key in registry. for eg. u can store Hpay and ZHOtel as "DWORD" valuse in registry while Name and Pname will be stored as "String". And while unstalling the applicaton, u can delete that particular key from Registy.
    Ayone pls. correct me if i'm wrong.
    Anita
    Can't imagine life without VB
    (Various Boyfriends)

  7. #7
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    There are lot of example on working with the registry on this forum.
    One of them is
    http://www.vbforums.com/showthread.p...e+registry+key
    Baaaaaaaaah

  8. #8
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Something like that is just begging to be stored in a txt file. I would not fool with a DB overhead for such a small amount of data. But then again it's too much for the registry.


    Use a Txt file.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  9. #9
    Hyperactive Member Jason Badon's Avatar
    Join Date
    Feb 2001
    Location
    Colorado
    Posts
    329
    this might help you get started if you want to use a text file

    VB Code:
    1. Dim Cities(1 To 15) As CityType
    2.  
    3. Private Type CityType
    4.     Name As String
    5.     PName As String
    6.     HPay As Integer
    7.     Hotel As Integer
    8. End Type
    9.  
    10. Private Sub Form_Load()
    11.     Dim i As Integer
    12.     For i = LBound(Cities) To UBound(Cities)
    13.         Let Cities(i).Name = "Name " & Str(i)
    14.         Let Cities(i).PName = "PName " & Str(i)
    15.         Let Cities(i).HPay = i
    16.         Let Cities(i).Hotel = i
    17.     Next i
    18. End Sub
    19.  
    20. Private Sub Command1_Click()
    21.     Dim FF, i As Integer
    22.     Let FF = FreeFile
    23.     Open App.Path & "\cities.txt" For Append As #FF
    24.    
    25.     For i = LBound(Cities) To UBound(Cities)
    26.         Print #FF, Cities(i).Name & "," & Cities(i).PName & "," & Str(Cities(i).HPay) & "," & Str(Cities(i).Hotel)
    27.     Next i
    28.    
    29.     Close #FF
    30. End Sub
    31.  
    32. Private Sub Command2_Click()
    33.     Dim strSplit() As String
    34.     Dim i As Integer
    35.    
    36.     strSplit = Split(GetCityType(3, (App.Path & "\cities.txt")), ",")
    37.    
    38.     For i = LBound(strSplit) To UBound(strSplit)
    39.         MsgBox strSplit(i)
    40.     Next i
    41. End Sub
    42.  
    43. Private Function GetCityType(intCityToGet As Integer, strFileName As String) As String
    44.     Dim FF, i As Integer
    45.     Let FF = FreeFile
    46.     Let i = 1
    47.     Dim strName, strPName, strHPay, strHotel As String
    48.    
    49.     Open strFileName For Input As #FF
    50.     Do While Not EOF(FF)
    51.         Input #FF, strName, strPName, strHPay, strHotel
    52.         If i = intCityToGet Then Exit Do
    53.         i = i + 1
    54.     Loop
    55.    
    56.     Let GetCityType = strName & "," & strPName & "," & strHPay & "," & strHotel
    57. End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width