jayR Posted June 1, 2006 Share Posted June 1, 2006 Ok, so I need to connect to my Access database. I found a tutorial and followed it and it works fine. The code I used from that tutorial is this:<?php$conn = new COM("ADODB.Connection") or die("Cannot start ADO"); // Microsoft Access connection string.$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\filepath\\db.mdb");// SQL statement to build recordset.$rs = $conn->Execute("SELECT Priority FROM Priority");echo "<p>Below is a list of values in the MYDB.MDB database, MYABLE table, MYFIELD field.</p>";// Display all the values in the records setwhile (!$rs->EOF) { $fv = $rs->Fields("Priority"); echo "Value: ".$fv->value."<br>\n"; $rs->MoveNext();} $rs->Close(); ?>Everything prints out well, so I thought I was set. However, when I change the file to something like this:<?php$conn = new COM("ADODB.Connection") or die("Cannot start ADO"); // Microsoft Access connection string.$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\filepath\\db.mdb");// SQL statement to build recordset.$rs = $conn->Execute("insert into Priority(Priority) values ('InsertedData')");$rs->Close(); ?>I get an error that reads: Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft OLE DB Provider for ODBC Drivers<br/><b>Description:</b> [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.' in C:\wamp\www\access.php:5 Stack trace: #0 C:\wamp\www\access.php(5): com->Open('DRIVER={Microso...') #1 {main} thrown in C:\wamp\www\access.php on line 5Maybe I misunderstood, but I thought you just put your sql after the Execute(" section and let it do its thing, but thats obviously not working so I'm hoping someone can point me in the right direction. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/10961-inserting-problem/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.