Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Form Alter DNS Connection - Code 1

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
0
0
AU
I have an old vb6 program that has a lot of forms generated by Add Form. I have used odbc to connected to the database.
ie ODBC setup in Control panel..

I want to use several copies of the program on the same machine. ie each program opening a different .mdb

I was thinking of having several odbc connections to the database ie DB1 Db2 Db3 , set up on the computer control panel.

Is there a way of altering the DNS on FormLoad ie Providor= etc... i have had a pretty good go at it, and cannot get a result.

Appreciate any help



 
To begin with, you don't need multiple ODBC DSN's. You can have several programs all using a single ODBC DSN. However, if you insist on multiple DSN's, all you need to do is to capture the DSN name into a string variable and use that in your open statements...



Good Luck

 
I am using the same .exe ... but am running in different directories.

Each directory has it own databbase .mdb

When i open a form i need to bind it to the .mdb in that directory.. ie. vary depending in which directory we are running..

I have done the following and it seems to work

In form load.....VUserDsn is the control panel ODBC

Dim db As ADODB.Connection
Set db = New ADODB.Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDASQL;dsn=" & VUserDsn & ";uid=;pwd=;"

Set adoPrimaryRS = New ADODB.Recordset

There is probably a better way... but i suppose if it works.
All is ok

Appreciate your interest in my problem

Regards Kennedymr2
 
Well, if you are using access and using ADO then please see to view an ODBC DNS Less connection string that you can use and all you have to do is to replace the path to the mdb kind of like you have done with the ODBC DSN. Which means that if you are constantly adding new databases of the same design, you will not need to constantly create new ODBC DSN's.



Good Luck
 
vb5prgrmr

Thankyou for your advice, much appreciated

Regards Kennedymr2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top