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

Posted on 2010-04-06
Medium Priority
Last Modified: 2012-05-09
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.

Question by:Radhs74
  • 3
LVL 97

Expert Comment

by:Lee W, MVP
ID: 29944150
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.

Author Comment

ID: 29945869
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

LVL 14

Accepted Solution

VBClassicGuy earned 1500 total points
ID: 29956305
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.


Author Comment

ID: 30024283
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

Author Closing Comment

ID: 31711527

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question