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

Hello, I am trying to access SQL server database through perl ADO. Here is the sample code I use:
use strict; use Win32::OLE; my $Conn; my $RS; $Conn = Win32::OLE->new("ADODB.Connection","Close") or die "ADO New Co +nnection failed $!"; $RS = Win32::OLE->new("ADODB.Recordset") or die "ADO New Recordset fai +led $!"; $Conn->Open("DSN=ENG_DB;UID=enguser;PWD=yt12xcj") or die "ADO Connecti +on open failed $!"; $RS->Close; $Conn->Close;
It fails at $Conn->Open line, but I can use the same Connection String("DSN=ENG_DB;UID=enguser;PWD=yt12xcj") in VB program successfully. Any idea or suggestion will be greatly appreciated! Thanks.

edited: Mon Jul 1 18:47:35 2002 by jeffa - title change

Replies are listed 'Best First'.
Re: ADO
by kodo (Hermit) on Jul 01, 2002 at 09:50 UTC
    It's just an idea, but I would try Open("DSN=ENG_DB, UID=enguser, PWD=yt12xcj") instead of seperating it with semicolons.

    giant
      <guessing>
      Or even: Open("DSN=ENG_DB", "UID=enguser", "PWD=yt12xcj"); </guessing>

      SMiTZ
Re: ADO
by Courage (Parson) on Jul 01, 2002 at 16:20 UTC
    The point is simple -- your $Conn->Open(...) opens database correctly, but your code just did not noticed that.

    Try in your code for example following:

    $Conn->Open("DSN=ENG_DB;UID=enguser;PWD=yt12xcj"); print '[[',$Conn->{DefaultDatabase},"]]\n";
    but when you intentionally break your code to, say,
    $Conn->Open("DSN=BADBADENG_DB;UID=enguser;PWD=yt12xcj"); print '[[',$Conn->{DefaultDatabase},"]]\n";
    you'll see a difference!

    I just modelled this situation on my computer.

    BTW when searched a documentation, I noticed that VB sample code from MSDN does not checks for return code, it probably relies on On Error statement

    Courage, the Cowardly Dog

      Courage, Yes, you are perfectly right. Thank you very much!