Variant is your friend...  Know it, Love it, Use it!

It's a pain sometimes to determine what to use for the type of variant,
but trial and error usually works too..  :)

You also had a usage issue (cursor needs to be before the open), and you
should use error trapping for OLE errors, like below, but better..

Cheers!

Steven

<%
use Win32::OLE;
use Win32::OLE::Variant;
$strConnect = 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ='
.$Server->MapPath('/aspgrid/db/aspgrid.mdb');
$Grid = $Server->CreateObject('Persits.Grid');
$Conn = $Server->CreateObject('ADODB.Connection');
$Conn->Open($strConnect);
$RecSet = $Server->CreateObject('ADODB.Recordset');

$RecSet->{CursorLocation} = 3;
$RecSet->Open('select id, name, phone from departments', $Conn, 2, 3);
$this = Variant(VT_BYREF|VT_VARIANT,$RecSet);
$Grid->{Recordset} = $this;
if (Win32::OLE->LastError() != 0) {
  $Response->Write("Help\n".Win32::OLE->LastError());
  exit 0;
}
$Grid->Cols('id')->{Hidden} = 1;
$Grid->{ImagePath} = '/aspgrid/images/';
$Grid->Display();
$Grid->Disconnect();
$Grid = undef;
$Conn = undef;
%>

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Carl Ringwall
Sent: Thursday, March 10, 2005 3:19 PM
To: 'perl-win32-web@listserv.ActiveState.com'
Subject: Persits IIS component ASPGrid


I'm having a bit of trouble with Persits ASPGrid, the documentation has
this
bit of VBScript code:
Begin VBS
__________________________
' Build connection string to aspgrid.mdb
        strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
Server.MapPath("..\db\aspgrid.mdb")

        ' Create an instance of AspGrid
        Set Grid = Server.CreateObject("Persits.Grid")

        ' Create ADO Connection
        Set Conn = Server.CreateObject("ADODB.Connection")
        Conn.Open strConnect

        ' Create Recordset
        Set RecSet = Server.CreateObject("ADODB.Recordset")
        RecSet.CursorLocation = 3 ' adUseClient
        RecSet.Open "select id, name, phone from departments", Conn, 2,
3

        ' Pass external connection object to grid
        Grid.Recordset = RecSet
        
        ' Hide identity column
        Grid.Cols("id").Hidden = True

        ' Specify location of button images
        Grid.ImagePath = "../images/"
        
        ' Display grid
        Grid.Display

        ' Disconnect
        Grid.Disconnect

        ' Destroy Grid object
        Set Grid = Nothing

        Set Conn = Nothing
_______________________
End VBS

Here is my PerlScript Equivalent:

Begin PerlScript
______________________________________
$strConnect = 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=' .
$Server->MapPath('..\\db\\aspgrid.mdb');
$Grid = $Server->CreateObject('Persits.Grid');
$Conn = $Server->CreateObject('ADODB.Connection');
$Conn->Open($strConnect);

$RecSet = $Server->CreateObject('ADODB.Recordset');


$RecSet->Open('select id, name, phone from departments', $Conn, 2, 3);
$RecSet->{CursorLocation} = 3;
$Grid->{Recordset} = $RecSet;
#line 25 is the next line
$Grid->Cols('id')->{Hidden} = 1;
$Grid->{ImagePath} = '../images/';
$Grid->Display();
$Grid->Disconnect();
$Grid = undef;
$Conn = undef;

_______________
End PerlScript

I'm getting this error in the browser:
PerlScript Error (0x80004005)
(in cleanup) Can't use an undefined value as a HASH reference 
/aspgrid/02_first/_ts3tmp.asp, line 25 is noted in the code.

Any syntax problems that anyone can see?  I'm stuck.
_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to