Jump to content

Cannot open with Jet.


jarv

Recommended Posts

Is my code ok?

 

<?php


$db = 'C:\\Inetpub\\wwwroot\\php\\db\\tellist.mdb';

$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');

$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db") or exit('Cannot open with Jet.');

$sql = 'SELECT * FROM phonebook';

$rs = $conn->Execute($sql);

?>

<table>
<tr>
<th>Client</th>
<th>Name</th>
<th>Number</th>
</tr>
<?php while (!$rs->EOF) { ?>
<tr>
	<td><?php echo $rs->Fields['rsClient']->Value ?></td>
	<td><?php echo $rs->Fields['rsName']->Value ?></td>
	<td><?php echo $rs->Fields['rsNumber']->Value ?></td>
</tr>
<?php $rs->MoveNext() ?>
<?php } ?>
</table>

<?php

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

$rs = null;
$conn = null;

?>

Link to comment
Share on other sites

ok I changed the JET line 8 and now line 8 looks like this:

 

$conn->Open("Microsoft Access Driver ; Data Source=$db");

 

this is my error:

 

PHP Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft OLE DB Provider for ODBC Drivers

Description: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified' in C:\Inetpub\wwwroot\php\test.php:8 Stack trace: #0 C:\Inetpub\wwwroot\php\test.php(8): com->Open('Microsoft Acces...') #1 {main} thrown in C:\Inetpub\wwwroot\php\test.php on line 8

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.