none
can't get sqlsrv_ts.dll to connect from IIS server to remote sql srv

    Question

  • THANK YOU so much for your help.
    ENVIRONMENT:
    Microsoft, IIS 7.0 & PHP 5 on 2003 Server No.1 & SQL 2000 on 2003 Server No.2
    I AM able to connect using the below syntax just fine:

    $connection_string = 'DRIVER={SQL Server};SERVER=FQDN_NAMEOFSQLSRV;DATABASE=MYDBNAME';
    $user = 'MYNAME';
    $pass = 'MYPASWRD';
    $connection = odbc_connect( $connection_string, $user, $pass )

    In other words, built in built in ODBC works fine.  

    PROBLEM STATEMENT:  I am unable to connect using the sqlsrv extension.
    I verified with phpinfo that sqlsrv extension (using sqlsrv_ts.dll) is loading fine, but the below syntax does NOT work

    $serverName = "(FQDN_NAMEOFSQLSRV)";
    $conn = array( "Database"=>"MYDBNAME", "UID"=>"MYNAME", "PWD"=>"MYPASWRD");
    $conn = sqlsrv_connect( $serverName, $conn)

    I have version 8.00.194 of ntwdblib.dll in sys32 dir and in c:\php\ and IUSR has full control over it.
    At this point, I'm not worried about security, so much as getting this thing to work.  I can tighten down later if need be.  So I also gave IUSR read/write over the sql server subkey in the registry odbc hive
    My problem is that the customer in this case wants to use the sqlsrv extension and associated functions, not the built-in ODBC and not DSN.  

    I do not have the SQL client connectivity tools installed on this IIS server even though the SQL server is remote.  I'd prefer to avoid that if possible.

    Thanks again :-)
    ~p
    Tuesday, February 26, 2008 2:50 PM

All replies

  • What is the error you are getting?

     

    Tuesday, February 26, 2008 9:53 PM
  • BTW, here's an update:

    I installed SQL client connectivity tools, and now I got the more traditional (and php team supported 'official') extension called mssql_connect to work, and select/print from tables works ok now with EITHER the odbc_connect or mssql_connect.  But I'm still not able to get sqlsrv_connect to work.

    Here is the code I'm trying to use:

    ===========//BEGIN QUOTE//==========
    <?php
    /* Specify the server and connection string attributes. */
    $serverName = "(subname.subname2.parent.topname)";

    /* Get UID and PWD from application-specific files.  */
    $uid = ("myuserid");
    $pwd = ("mypw");
    $connectionInfo = array( "UID"=>$uid,
                             "PWD"=>$pwd,
                             "Database"=>"testdb");

    /* Connect using SQL Server Authentication. */
    if( !( $conn = sqlsrv_connect( $serverName, $connectionInfo)))
    {
         echo "Unable to connect.</br>";
         die( print_r( sqlsrv_errors(), true));
    }


    /* Free statement and connection resources. */
    sqlsrv_free_stmt( $stmt);
    sqlsrv_close( $conn);
    ?>
    ===========//END QUOTE//==========


    Here is the error I get:
    ===========//BEGIN QUOTE//==========
    Unable to connect.
    Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 53 [code] => 53 [2] => [Microsoft][SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [53]. [message] => [Microsoft][SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [53]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Native Client]Login timeout expired [message] => [Microsoft][SQL Native Client]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 53 [code] => 53 [2] => [Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. [message] => [Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. ) )
    ===========//END QUOTE//==========



    Thanks,
    ~p
    Monday, March 03, 2008 9:36 PM