http://www.perlmonks.org?node_id=129027

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am currently at the design stage of a system that will have parts of it written in perl. this system will be accessing multiple database servers which will be able to be added and removed from the system at anytime. Because of this I don't want to be giving the server with the system on it a dsn for every database server so what I am asking is .... is there a way of just reading details of a server from a database (no probs there) and then just from that info making contact to the external DB server. eg dynamically creating dsn's?

(hope this made sense)

btw this system will be run under a windows environment (I would rather *nix but this was not possible with some of the specifications)

Thanks in advance.

Matthew Frick
mfrick@learnedsolutions.com

Replies are listed 'Best First'.
(crazyinsomniac) Re: DSN's
by crazyinsomniac (Prior) on Dec 03, 2001 at 07:37 UTC
Re: DSN's
by strat (Canon) on Dec 04, 2001 at 20:24 UTC
    By the way: if you are looking for the options to Win32::ODBC::ConfigDSN, just enter a DSN manually and then goto Registry into the following Branch:
    SystemDsn: HKEY_LOCAL_MACHINE\Software\ODBC
    UserDsn: HKEY_CURRENT_USER\Software\ODBC
    and browse through the subdirectories. If there you find a value like "Thrusted_Connection" with the value "Yes", then just use it about like that:
    if (Win32::ODBC::ConfigDSN( ODBC_ADD_SYS_DSN, "SQL Server", ( "DSN=$dsn", "DESCRIPTION=$dsnDescription", "SERVER=$sqlServer", "DATABASE=$database", "UID=$uid", "PWD=$password", "Trusted_Connection=Yes", ) ) ){ print ("DSN $dsn sucessfully created\n");
    That example was taken from MsSql-Server, but for the other ones it's just the same way.