Results 1 to 5 of 5

Thread: ADODB Record Count? / NEW COM (my dll file)?

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    ADODB Record Count? / NEW COM (my dll file)?

    OK, i was trying to find out how to implement an activex dll in php, and come accross the com function.
    http://www.php.net/manual/en/ref.com.php

    [and whoo, can do the (practically - at least) same as with VB]
    Anyhow: Record count is returning the value "-1" as if there isn't any records / connection doesnt exsist.

    Does any one know what could be the problem?

    PHP Code:
    <?php
        $pagetitle 
    " - Online Users";
        include(
    "header.php");
        
    title("Users Currently In The Chat Server");
        
    OpenTable();

        echo 
    "<table align=\"center\" width=\"400\">\n";
        echo 
    "<tr>";
        echo 
    "<td align=\"center\"><b>Username</b></td>";
        echo 
    "<td align=\"center\"><b>Location URL</b></td>";
        echo 
    "<td align=\"center\"><b>Login Time</b></td>";
        echo 
    "</tr>";

        
    // Create the database connection
        
    $conn = new COM("ADODB.Connection"); 
        
    $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\Programming\TheWalksChat\ChatServer\online.mdb");

        
    // Create a new record set
        
    $rs = new COM("ADODB.Recordset");
        
    // open the record set, and select the Username / Location URL / Time Logged In
        
    $rs->Open("select Username, LocationURL, Login_Time from online"$conn); 

                    
    // This is the record count part <<<<<<<<<<<<<<<<<<<<<<<<
        
    echo $rs->recordcount() ." users online";

        
    // Loop through all of the records in the record set
        
    while (!$rs->EOF){

            
    $username $rs->Fields(0);
            
    $locationurl $rs->Fields(1);
            
    $login_time $rs->Fields(2);

            
    $username $username->value;
            
    $locationurl $locationurl->value;

            
    //then start writing the cells in the row, and move to the next record
            
    echo "<tr>";
            echo 
    "<td align=\"center\"><a href=\"modules.php?name=Your_Account&amp;op=userinfo&amp;uname=" $username "\">" $username "</a></td>";
            echo 
    "<td align=\"center\"><a href=\"" $locationurl "\" target=\"_self\">" $locationurl "</a></td>";
            echo 
    "<td align=\"center\">" $login_time->value "</td>";
            echo 
    "</tr>";

            
    // Move to the next record
            
    $rs->movenext();

        }

        
    //close the ADO connections and release resources
        
    $rs->Close(); 
        
    $conn->Close(); 
        
    $rs null
        
    $conn null;

        echo 
    "</table>";

        
    CloseTable();
        include(
    "footer.php");
    ?>

    NEXT:
    how can i load my own DLL file using the com function, i have tried tons, and cant seam to fix it :\ - ne 1 help me?
    Wayne

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    what server are you on?

  3. #3
    Member
    Join Date
    May 2001
    Posts
    39

    Problem: bad CursorType

    Probably you have open a ForwardOnly recordset (the type for default). If you need to use the RecordCount property open a Static recordset, you can do this by making the CursorType equal to 3 (i think). Is one of the parameters of the Open method.

  4. #4

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    PHP Man:

    Win 2k Pro - Apache - PHP 4.3

    Desbaratizador:

    Probally might be the reason, since i had to open my vb record set like dat to fix the record count.

    VB Code:
    VB Code:
    1. PreURLs.Open "SELECT ConIndex FROM online WHERE LocationURL='" & PreURL & "'", oConnR, adOpenKeyset, adLockBatchOptimistic

    What r the php equals to these settings?
    VB Code:
    1. , adOpenKeyset, adLockBatchOptimistic

    or should i be able to do it like
    PHP Code:
    $rs->Open("select Username, LocationURL, Login_Time from online"$conn"3""1"); 
    or?
    Wayne

  5. #5

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    : idea, i tried it like i just posted (added
    PHP Code:
    "3""1" 
    to the open function, and it works
    Wayne

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width