Results 1 to 6 of 6

Thread: how to put db connection in my ini

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    46

    how to put db connection in my ini

    I have just made an ini file called "irs.ini"
    I have stored this in my c:\ directory.

    it looks like this:

    [connectionfile]
    dbconstring = c;\irs\irs1.mdb


    Now I want to get the value from the ini and set it to a variable in my VB project so my database can hook up via the value in the ini file. It is so the host machine for my application can access the db as wel las the client machines.

    Anyone offer some help?

  2. #2
    Fanatic Member
    Join Date
    Feb 2003
    Location
    Los Angeles, CA
    Posts
    681
    i'm sure you will get an answer about how to save and retrieve from ini's. however you may use 2 or 3 other methods that are more 'contemporary':
    (A) save the database path in the registry, instead of saving in an ini. use the standard GetSetting() and SaveSetting() functions for that
    OR (B) save a connection string instead of the database filename
    OR (C) use a fixed-name DSN file that you would distribute with your application
    there are 2 reasons why i leave my work unfinished:
    (1) i'm getting old.

  3. #3
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692
    Check here there should be a function there called ReadINI. It will show you how you can put the value of a specific key whereever you need to put it.

  4. #4
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    Originally posted by radum
    i'm sure you will get an answer about how to save and retrieve from ini's. however you may use 2 or 3 other methods that are more 'contemporary'...
    Contemporary doesn't necessary means BETTER. Registry is the worst place to store critical information such DB related info as it (registry) can be very easily overwritten on every system restart from LAN (this method has been used by many corps where security is strictly enforced), besides most of the users don't even have permissions to access registry at all. So, I'll let you decide what's better: contemporary or SAFE.
    McGenius

  5. #5
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    How I do it :

    [CONNECTIONS]
    'A = MICROSOFT ACCESS DATABASE
    'B = MICROSOFT SQL DATABASE
    'C = ORACLE DATABASE

    A= Provider=Microsoft.Jet.OLEDB.4.0; Data Source=
    B=
    C=

    CONNTYPE = A

    This way I can change the connection type and the type of database in my ini file...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  6. #6
    Fanatic Member
    Join Date
    Feb 2003
    Location
    Los Angeles, CA
    Posts
    681
    Originally posted by McGenius
    Contemporary doesn't necessary means BETTER. Registry is the worst place to store critical information such DB related info as it (registry) can be very easily overwritten on every system restart from LAN (this method has been used by many corps where security is strictly enforced), besides most of the users don't even have permissions to access registry at all. So, I'll let you decide what's better: contemporary or SAFE.
    agreed, and dsn files can be used in this situation. however changing that registry entry upon network login or some other events may be exactly the desired effect, especially if the database keeps moving around. 'better' or 'worse' qualifiers is what i was trying to avoid, by naming them 'contemporary'.
    there are 2 reasons why i leave my work unfinished:
    (1) i'm getting old.

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