PHP in DSN Less Conection Database Ms-Access

Discussion in 'PHP' started by itsys, Jul 1, 2009.

  1. itsys

    itsys Banned

    Joined:
    May 2, 2009
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    PHP:
    <?php

    //create an instance of the  ADO connection object
    $conn = new COM ("ADODB.Connection")
      or die(
    "Cannot start ADO");

    //define connection string, specify database driver
    $connStr "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= C:\\wamp\\www\\test1\\database\\directorydb.mdb";
      
    $conn->open($connStr); //Open the connection to the database

    //declare the SQL statement that will query the database
    $query "SELECT Category FROM tblCategories";

    //execute the SQL statement and return records
    $rs $conn->execute($query);

    $num_columns $rs->Fields->Count();
    echo 
    $num_columns "<br>";

    for (
    $i=0$i $num_columns$i++) {
        
    $fld[$i] = $rs->Fields($i);
    }

    echo 
    "<table>";

    while (!
    $rs->EOF)  //carry on looping through while there are records
    {
        echo 
    "<tr>";
        for (
    $i=0$i $num_columns$i++) {
            echo 
    "<td>" $fld[$i]->value "</td>";
        }
        echo 
    "</tr>";
        
    $rs->MoveNext(); //move on to the next record
    }


    echo 
    "</table>";

    //close the connection and recordset objects freeing up resources
    $rs->Close();
    $conn->Close();

    $rs null;
    $conn null;
    ?>
     
    Last edited by a moderator: Jul 1, 2009
  2. itsys

    itsys Banned

    Joined:
    May 2, 2009
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    I have Create DSN Less Connection. Data Source= C:\\wamp\\www\\test1\\database\\directorydb.mdb";
    I have give the full path data base. When the uplode appliction on server. what changes the path
    Thanaks
     
    Last edited by a moderator: Jul 1, 2009
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Use Code blocks for Code snippets in posts and also confine links to signatures only
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice