perlquestion
enoch
I am running the following code:
<CODE>
use strict;
use OLE;
my $Conn;
my $RS;
$Conn = CreateObject OLE "ADODB.Connection"; #Create a connection for MS-SQL
$Conn->Open("DSN=WIN;UID=db;PWD=passwd;"); #Open the ODBC named WIN
$RS = $Conn->execute("select user from accounts where user = 'test'");
if (!$RS)
{
my $Errors = $Conn->Errors();
my $error;
foreach $error (keys %$Errors)
{
print $error->{Description}, "\n";
}
}
else
{
print "The username is $RS->Fields(0)->value.\n";
}
$Conn->Close;
</CODE>
When this code runs, I get the output:
<P><CODE>
The username is OLE=HASH(0x827ea0)->Fields(0)->value.
</CODE><P>
That is, it is resolving the value of the <CODE>$RS->Fields(0)->value</CODE> to an OLE hash of some kind. What I want is the value of that field. I looked around on PerlMonks, and found exactly the same code snippets but no discussion on this phenomenon.<BR>
This is running on Windows2000 connecting to MS-SQL7 with ActiveState Perl.
<BR><BR>
Jeremy