in reply to Setting CommandTimeout

In "$Conn->CommandTimeout = 120;" you are attempting to set the value of a subroutine (lvalue).

That is the way the command is written in VB(A).

For perl, try:

$Conn->CommandTimeout ( 120 );
I dont think this syntax is right either:
$RS = $Conn->Execute( $sql,CommandTimeout=120);
but I'm unfamiliar with this approach for SQL/Win32::OLE.

        This is not an optical illusion, it just looks like one.

Replies are listed 'Best First'.
Re^2: Setting CommandTimeout
by amitvalia (Novice) on May 05, 2016 at 22:37 UTC
    When you run

    $RS = $Conn->Execute( $sql,CommandTimeout=120);

    you get an error

    Can't modify constant item in scalar assignment But the line $Conn->CommandTimeout ( 120 );

    Worked when compiling. But still did not change the CommandTimeout value.

    <%@ LANGUAGE = PerlScript%> <html> <body> <% $Conn = $Server->CreateObject("ADODB.Connection"); $Conn->Open( "Provider=SQLOLEDB;User ID=user;Password=pswd;Initial Cat +alog=db;Data Source=server" ); $Conn->CommandTimeout(120); %> Command Timeout is now =<% =$Conn->CommandTimeout%> <% $RS = $Conn->Execute( "SELECT 19000000+max(yymmdd) FROM tehachapi. +.bso688d" ); $yymmdd=$RS->Fields(0)->{Value}; $RS->Close; $Conn->Close; %>

    This is what the is printed

    Command Timeout is now =30

      I meant to say

      $Conn->CommandTimeout(120)

      Didnt give a compile error. But it didn't set the commandtimeout value either.

        I think you are running into some weirdness of the CommandTimeout property, as described in msdn.

        The CommandTimeout setting on a Connection object has no effect on the CommandTimeout setting on a Command object on the same Connection; that is, the Command object's CommandTimeout property does not inherit the value of the Connection object's CommandTimeout value.

        I suggest you create a command object, assign the Connecttimeout to the command, then execute the SQL from there.
        See this VBA discussion of the failure of CommandTiemout.

                This is not an optical illusion, it just looks like one.