How to change the connection parameters in VB 6.0 for DB Server

I have about 3 important dbs , two on one server with "xx" as domain and one on another server with "yy" domain , but we wanted to get all the 3 dbs on to server with "xx" domain , now I want to know instead of changing the VB code , can I do it using an INI file and as they are frequently changing the db servers , I only need to change the INI file instead of the VB code
and what is the procedure to do so that it takes the connection from the INI file and not from the VB code .If there are any other suggestions would greatly appreciate.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee W, MVPTechnology and Business Process AdvisorCommented:
I'd probably use the registry... and I'm not sure how, exactly, you're trying this, but instead of hard-coding servers, database names, user names, and passwords, why not use variables in their place and then you can have the variables determined by reading from the registry.
Radhs74Author Commented:
I want to  know how to do that if I got to declare those variables and what should be done in the registry and the procedures involved in it

I have a subroutine called GetDBConnString where I build the connect string from an INI file. Here is a snippet:
   SQL$ = "Provider=" & GetIni$(1, "Database", "Provider")
   SQL$ = SQL$ & ";Persist Security Info=FALSE"
   SQL$ = SQL$ & ";User ID=" & GetIni$(1, "Database", "UserID")
   SQL$ = SQL$ & ";Password=" & GetIni$(1, "Database", "Password")
   SQL$ = SQL$ & ";Initial Catalog=" & GetIni$(1, "Database", "InitCat")
   SQL$ = SQL$ & ";Data Source=" & GetIni$(1, "Database", "Source")
   SQL$ = SQL$ & ";Connect Timeout=" & GetIni$(1, "Database", "Timeout")
   SQLFileSpec$ = SQL$
SQLFileSpec$ is declared as Public, so my whole program can use it. The GetIni$ function just returns the value from the patricular INI file I'm using. I use it like:
txt$ = GetIni$(WhichINI%, "ScopeName", "VariableName")
That could easily be replaced with registry calls, GetSetting for putting data into the registry, PutSetting for putting them in, like:
txt$ = GetSetting("YourProgramName", "Database", "Provider")
Look them up in your on-line help. Anyway, then I have a dialog that looks like the attached picture.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Radhs74Author Commented:
Hi VBClassicGuy:

Thanks for your input , would greatly appreciate if you can send the procedures that I have to follow in setting up in the registry

Thanks a lot for your time and cooperation
Radhs74Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.