Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How do I create/remove ODBC DSN entries under Windows (Win32)?

by Discipulus (Canon)
on Feb 18, 2005 at 09:05 UTC ( [id://432220]=note: print w/replies, xml ) Need Help??


in reply to How do I create/remove ODBC DSN entries under Windows (Win32)?

hallo monks, like always there is more then one way..I used directly the registry and it works fine. this way permit to create easely system DSN on remote machines. The follow code is only the sub which create the DSN but with Tie::Registry is easier destroy then create.
#!perl #(...) use Win32::TieRegistry ( Delimiter=>"/" ); #(...) sub Crea_dsn ################################################## { my $ip = shift; my $dbq= shift; my $nuovo_dsn= shift; my $descrizione="DB utente "; unless( $registry_remoto = $Registry->Connect( "$ip", "LMachine" )){r +eturn "Errore connessione registry remoto: $^E"} my $odbc_ini = $registry_remoto->{"Software/ODBC/ODBC.INI"}||return " +$^E"; my $odbc_data_sources= $odbc_ini->{"ODBC Data Sources"}||return "$^E" +; foreach my $dsn(sort keys %{$odbc_data_sources}) { $dsn=~s/\///; $dsn eq $nuovo_dsn ? return "$nuovo_dsn gia\' in uso\n" : +next; } $odbc_data_sources->{$nuovo_dsn} = "Microsoft Access Driver (*.mdb)"| +|return "$^E"; $odbc_ini->{$nuovo_dsn}={'DBQ'=>$dbq, 'Description'=>$descrizione, 'Driver'=>'C:\WINNT\System32\odbcjt32.dll', 'DriverID'=>['0x00000019','REG_DWORD'], 'FIL'=>'MS Access;', 'SafeTransactions'=>['0x00000000','REG_DWORD' +], 'UID'=>'', 'Engines'=>{ 'Jet'=>{'ImplicitCommitSync'=>'' +, 'MaxBufferSize'=>['0x0000 +0800','REG_DWORD'], #(hex(800)) da 2048 'PageTimeout'=>['0x000000 +05','REG_DWORD'], 'Threads'=>['0x00000003', +'REG_DWORD'], 'UserCommitSync'=>'yes' } } }||return "$^E"; return ("creato DSN: $nuovo_dsn su $dbq"); }
I hope this can help
cheers from sunny roma Lor*
  • Comment on Re: How do I create/remove ODBC DSN entries under Windows (Win32)?
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://432220]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found