1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP+Ms Access_Conection without dsn

Discussion in 'PHP' started by itsys, Jun 23, 2009.

  1. itsys

    itsys Banned

    Joined:
    May 2, 2009
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    PHP:
    <?php
    $conn 
    = new COM('ADODB.Connection') or exit('Cannot start ADO.');
    $db 'C:\\wamp\\www\\test1\\database\\directorydb.mdb';
    $conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db") or exit('Cannot open with Jet.');
    $sql ='SELECT Category FROM tblCategories';
    $rs $conn->Execute($sql,$db);
    ?>
    <table>
    <tr>
        <th>Category</th>
    </tr>
    <?php while (!$rs->EOF) { ?>
         <tr>
            <td><?php echo $rs->Fields['Category']->Value ?></td>
        </tr>
        <?php $rs->MoveNext() ?>
    <?php 
    ?>
    </table>

    <?php

    $rs
    ->Close();
    $conn->Close();

    $rs null;
    $conn null;

    ?>
    i have create connection occure error "Cannot open with Jet."
    pls, correct the code
     
    Last edited by a moderator: Jun 23, 2009
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Please get the exact error message.
     

Share This Page