Problem inserting to an Access database

A

Alan Chiew

Hi All,

The following piece of code is what I have tried to update a simple
Access database (none of the commented out code worked either). The
connection to the database seems to be fine because I am able to read
data from it. However, when trying to add another row of data, nothing
seems to happen.

I have also checked the permissions in IIS and they seem to be set up
fine.

Any ideas would be much appreciated.

Regards,
Alan

<%@LANGUAGE = PerlScript%>

<%
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';

$Conn = Win32::OLE->new("ADODB.Connection");
$RS = Win32::OLE->new("ADODB.Recordset");

$DBFile = "E:\\vhosts\\internaltest\\public_html\\ITRtest.mdb";

$DSN = "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=$DBFile;UID=;PWD=;";

$Conn->Open($DSN);

$RS->Open("test", $Conn, adLockOptimistic, adOpenDynamic);

$fields = ["barcode", "desc"];
$values = ["C999", "this"];

$RS->AddNew($fields, $values);

#$Conn->Open("INSERT INTO test VALUES ('aaa', 'bbb')");
#$RS->Open($SQL, $Conn, 1, 1);

#$SQL = 'insert into test (barcode) VALUES "C999"';
#$RS = $Conn->Execute($SQL);

#$RS->AddNew;
#$RS->Fields('barcode')->{value} = "ABC";
#$RS->Update;


$RS->Close;
$Conn->Close;
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top