[dba-SQLServer]Auto Supply Connection stringsandpasswords to controls on forms(VB6 & SQL)

Francisco H Tapia my.lists at verizon.net
Fri Jul 25 14:06:46 CDT 2003


a connection string can be generated using a udl file (to that go to your
desktop (or any folder really)) create a text file and rename it to udl then
click it and set the connections to your db.  now rename it again to a .txt
file.

use this connection string and simply in a module somewhere and create a
public constant

CONST myConnStr as string = "your connection string"


for your ado objects you'll need to create a connection object and set it to
your ado objects such as


Dim conn as adodb.connection
set conn = new adodb.connection
conn.open myConnStr 'Your connection string

then it's just a matter of setting your recordsets to it

I personnally don't like the dataenvironment variable cuz it tends to cause
more problems than help but that's just mho.

most objects you can just set the connection by setting it as

rst.activeconnection = Conn 'after following the above connection object
settings

-Francisco
http://rcm.netfirms.com

On Friday, July 25, 2003 2:00 AM [GMT-8],
paul.hartland at fsmail.net <paul.hartland at fsmail.net> wrote:

: Any chance of anyone sending me some sample code of this, including
: how I tell the ADO Controls to use the connection string, I juts
: can't get my head round this one for some reason.....
:
: Thanks in advance..
:
: Paul Hartland
:
:
: From: "Francisco H Tapia" <my.lists at verizon.net>
: Date: Thu 24/Jul/2003 15:59 GMT
: To: <dba-sqlserver at databaseadvisors.com>
: Subject: Re: [dba-VB] [dba-SQLServer]Auto Supply Connection strings
: andpasswords to controls on forms(VB6 & SQL)
:
: I second Arthur's suggestion along w/ maybe get a little bit of sleep
: ;o).
: Having constants w/ the connection string is so nice cuz you can
: modify the
: connection string in one place only.
:
: -Francisco
: http://rcm.netfirms.com
:
: On Thursday, July 24, 2003 8:48 AM [GMT-8],
: Arthur Fuller <artful at rogers.com> wrote:
:
:: Although retrofitting it might be a little work, why don't you define
:: the connection string as a constant? Then you could find and replace
:: all the literal occurrences
::
:: "Those who would sacrifice liberty for security deserve neither."
:: -- Benjamin Franklin
::
:: -----Original Message-----
:: From: dba-vb-bounces at databaseadvisors.com
:: [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of
:: paul.hartland at fsmail.net
:: Sent: July 23, 2003 10:07 AM
:: To: dba-sqlserver at databaseadvisors.com; accessd at databaseadvisors.com;
:: dba-vb at databaseadvisors.com
:: Subject: [dba-VB] [dba-SQLServer]Auto Supply Connection strings and
:: passwords to controls on forms(VB6 & SQL)
::
::
:: To all,
::
:: I have a VB6 application which looks at a SQL Server 7 database
:: (which is on a development server), and I am using a mixture of
:: DataEnvironment and ADO Controls for the application.  However when
:: it's finshed It will be moved to the live server so that everyone can
:: gain access to it.  The problem being that when I move to the live
:: server I will have to remember to change all the ADO controls and the
:: DataEnvironment connection manually (I don't want to have to do this
:: if I can help it).
::
:: What I thought of doing is have a table consisting of the
:: ConnectionString, Username & Password and then a table of all the
:: form names and ADO Controls, and somehow looping through the tables
:: and setting the connections automatically.  This is where I am stuck,
:: I have created the tables and entered the connection strings etc, and
:: I can do the loop which will loop through the records, but I don;t
:: know how to set the connection strings, using the form names and ADO
:: Controls from the tables.
::
:: Am I being stupid in doing it this way ?
::
:: Is there a better way to do this ?
::
:: Can anyone help on this, as the application is almost finished.....?
::
:: Thanks for any help in advance....
::
:: Paul Hartland
::
::
::
__________________________________________________________________________
:: Join Freeserve http://www.freeserve.com/time/
::
:: Winner of the 2003 Internet Service Providers' Association awards for
:: Best Unmetered ISP and Best Consumer Application.
::
::
:: _______________________________________________
:: dba-SQLServer mailing list
:: dba-SQLServer at databaseadvisors.com
:: http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
:: http://www.databaseadvisors.com
::
:: _______________________________________________
:: dba-VB mailing list
:: dba-VB at databaseadvisors.com
:: http://databaseadvisors.com/mailman/listinfo/dba-vb
:: http://www.databaseadvisors.com
::
:: _______________________________________________
:: dba-SQLServer mailing list
:: dba-SQLServer at databaseadvisors.com
:: http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
:: http://www.databaseadvisors.com
:
:
: _______________________________________________
: dba-SQLServer mailing list
: dba-SQLServer at databaseadvisors.com
: http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
: http://www.databaseadvisors.com
:
:
: __________________________________________________________________________
: Join Freeserve http://www.freeserve.com/time/
:
: Winner of the 2003 Internet Service Providers' Association awards for
: Best Unmetered ISP and Best Consumer Application.
:
:
: _______________________________________________
: dba-SQLServer mailing list
: dba-SQLServer at databaseadvisors.com
: http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
: http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list