Yeah, now I've got a big number as the date/time which I presume is the number of
seconds since the epoch (12:00:01 Jan 1. 1970). Thanks!
However, I still can't seem to get this thing to update. I turned on warnings and the
following messages:
==================================================
OLE exception from "ADODB.Recordset":
The operation requested by the application is not supported by the provider.
Win32::OLE(0.1401) error 0x800a0cb3
in METHOD/PROPERTYGET "AddNew" at access.pl line 35
OLE exception from "ADODB.Field":
The operation requested by the application is not supported by the provider.
Win32::OLE(0.1401) error 0x80020009: "Exception occurred"
in PROPERTYPUT "Value" at access.pl line 36
OLE exception from "ADODB.Recordset":
The operation requested by the application is not supported by the provider.
Win32::OLE(0.1401) error 0x800a0cb3
in METHOD/PROPERTYGET "Update" at access.pl line 37
==================================================
Here's the full code:
==================================================
#!/usr/bin/perl -W
#=====<< Use the Win32 OLE module >>=====#
use Win32::OLE;
#=====<< Open Database & Get Recordset >>=====#
$conn = Win32::OLE->new("ADODB.Connection");
$conn->Open("DSN=AscentWeb;UID=ascent;PWD=ascent1");
$rs = $conn->Execute("select * from ActivityLog;");
#=====<< If Any Errors, Show Them and Stop >>=====#
if (!$rs)
{
$Errors = $conn->Errors();
die "Errors:\n", map { "$_->{Description}\n" } keys %$Errors;
};
#=====<< Display all Data from Recordset >>=====#
print "\n\nMessages from Access Database\n";
while(!$rs->EOF)
{
my $timestamp = ${$rs->Fields('TimeStamp')->Value};
my $user = $rs->Fields('User')->Value;
my $subject = $rs->Fields('Subject')->Value;
my $message = $rs->Fields('Message')->Value;
print "=" x 60 . "\n";
print "TimeStamp: $timestamp\n";
print "User: $user \n";
print "Subject: $subject \n";
print "Message: \n$message \n";
$rs->MoveNext();
};
#=====<< Append Value to Database >>=====#
$rs->AddNew();
$rs->Fields('User')->{Value} = "Bubba";
$rs->Update();
#=====<< Close Recordset & Database >>=====#
$rs->Close();
$conn->close();
====================================================
Any further suggestions would be greatly appreciated.
--Matthew
>>> "Sterin, Ilya" <[EMAIL PROTECTED]> 05/16/01 02:07AM >>>
Looks like it's not dereferencing $rs->Fields('mydate')->Value pointing to a
scalar. I am not familiar with ADO, but have you tried this
print ${$rs->Fields('mydate')->Value};
Ilya Sterin
-----Original Message-----
From: Matthew Tedder [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 16, 2001 1:20 AM
To: [EMAIL PROTECTED]
Subject: Date/Time's with ADO
Question: How can I read in and use Microsoft Access Date/Time values
using ADO?
my $mydate = $rs->Fields('mydate')->Value;
It gives the following: Win32::OLE::Variant=SCALAR(0x2109fcc)
when I try to print what was read.
Also... How do I append a row? The O'reilly Perl DBI book doesn't go
into this in any level of detail at all. Here's what I tried:
$rs->AddNew();
$rs->Fields('User')->Value = 'Fred';
$rs->Update();
It gives me the following error on the line where I try to assign 'Fred'
to the column: Can't modify non lvalue subroutine call
Any answers from someone in the know would be greatly appreciated.
--Matthew