Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by Discipulus (Canon)
on Feb 14, 2008 at 11:53 UTC ( [id://667913]=note: print w/replies, xml ) Need Help??


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

hello there !! in the spirt of the "there is more ways to do this" I offer my registry hacking solution to create an odbc connection to an Access db (it be can changed very easily in this way: create your new custom DSN and check the registry at LocalMachine/Software/ODBC/ODBC.INI and change the script in accord with your needs)
##at the beginning of the scripts use Win32::TieRegistry ( Delimiter=>"/" ); #then &create_dsn(10.0.0.55,'c:/your/path/aaa.mdb','myCustomDSN'); #here the good stuff!! sub create_dsn ##################################################### +####### { my $ip = shift; my $dbq= shift; my $nuovo_dsn= shift; my $descrizione="your description "; unless( $registry_remoto = $Registry->Connect( "$ip", "LMachine" )){r +eturn "Error connecting to remote registry: $^E"} my $odbc_ini = $registry_remoto->{"Software/ODBC/ODBC.INI"}||return " +$^E"; my $odbc_data_sources= $odbc_ini->{"ODBC Data Sources"}||return "$^E" +; #be carefull if there are no dsn on that machine then no "ODBC D +ata Sources" exists!! foreach my $dsn(sort keys %{$odbc_data_sources}) { $dsn=~s/\///; $dsn eq $nuovo_dsn ? return "$nuovo_dsn yet exists!! plz +try other name!!\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 ("created DSN: $nuovo_dsn on $dbq"); }
Your remaining task is the sub to delete it but is quite easy.

hope this help
Lor*
  • Comment on Re: How do I create/remove ODBC DSN entries under Windows (Win32)?
  • Download Code

Replies are listed 'Best First'.
Re: Answer: How do I create/remove ODBC DSN entries under Windows (Win32)?
by jdporter (Paladin) on Feb 14, 2008 at 16:52 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-23 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found