Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Remove ODBC Data Source - Win32::ODBC

by briglass (Initiate)
on Feb 15, 2005 at 21:20 UTC ( #431336=perlquestion: print w/ replies, xml ) Need Help??
briglass has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to remove an ODBC data source with Perl. So far I have the following code, but it freezes the compiler without giving an error message.

use Win32::ODBC; Win32::ODBC::ConfigDSN( ODBC_REMOVE_DSN, "DSN=TempDSN" );

Is there a better way to go about this?

~Brian

Comment on Remove ODBC Data Source - Win32::ODBC
Download Code
Re: Remove ODBC Data Source - Win32::ODBC
by FitTrend (Pilgrim) on Feb 15, 2005 at 22:23 UTC

    Brian,

    Maybe its not the code. You may want to check the permission of the user running the perl script. They (or localsystem) may not have sifficent permissions to remove the DSN.

    Hope this helps

Re: Remove ODBC Data Source - Win32::ODBC
by NetWallah (Abbot) on Feb 15, 2005 at 22:44 UTC
    Try inserting an empty second parameter , to fill in the placeholder for the DRIVER.

    ConfigDSN ( OPTION, DRIVER, ATTRIBUTE ... )

        ..."I don't know what the facts are but somebody's certainly going to sit down with him and find out what he knows that they may not know, and make sure he knows what they know that he may not know, and that's a good thing. I think it's a very constructive exchange," --Donald Rumsfeld

      I have sufficient permissions. Also, I checked the Win32::ODBC documentation and the driver parameter is not needed. For removing a data source, only the "DSN=" parameter is needed. Something else must be going on...
        I can reproduce the problem - it looks like a bug in the ODBC module.

        Here is a TESTED Workaround (Yes it DID remove the DSN):

        >perl -MWin32::ODBC -e "Win32::ODBC::ConfigDSN( ODBC_REMOVE_DSN,'', qq +(DSN=TempDB) );"
        Notice - you need the NULL STRING as the DRIVER parameter.
        Update: undef also seems to work there.

            ..."I don't know what the facts are but somebody's certainly going to sit down with him and find out what he knows that they may not know, and make sure he knows what they know that he may not know, and that's a good thing. I think it's a very constructive exchange," --Donald Rumsfeld

Re: Remove ODBC Data Source - Win32::ODBC
by legato (Monk) on Feb 17, 2005 at 15:07 UTC

    I would first attempt to remove and rebuild the Win32::ODBC module. If that fails, I would do a couple of things:

    • use strict; use warnings; this may help you diagnose your issue.
    • Make certain the user account that is running your script has permission to modify Windows' ODBC DSN entries.
    • Use the Perl debugger (perl -d) to exec your script. Trace into the module and see where the hang is occuring -- it may not be in the compiler, as you suggest, but something during execution.
    • Make sure you are checking return values and handling errors:
      use Win32::ODBC; Win32::ODBC::ConfigDSN(ODBC_REMOVE_DSN, "DSN=TempDSN") or die "Unable to remove DSN: ".Win32::ODBC::Error()."\n"
      I suggest this because it's possible your hang is during exit or some other oddity -- if the module can print an error before the hang, it is yet more diagnostic information. And, it's just good practice to do it.

    The Perl debugger can be daunting. If you have ActiveState's PDK, their GUI debugger is decent, and will be a little less confusing. If not, get the GUI debugger for free from CPAN. In fact, the latter is a better debugger (IMHO), but it does require a bit more knowledge to handle compared to the PDK debugger.

    Anima Legato
    .oO all things connect through the motion of the mind

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://431336]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-07-12 01:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (238 votes), past polls