> do you install the dsn as system-dsn in windows? ado runs only under odbc
> and you need the system-dsn.

ADO is a set of components. It uses OLE DB providers to connect to data
sources. And you don't need a system DSN to connect to a data source via
ADO. With DBI, I don't know, but with ADO, you'd use the Command-object to
work with stored procedures. You can define the direction of each Parameter
object by setting the Command-object's Direction-property:

1 = Input Parameter
3 = Input and Output parameter
2 = Output Parameter
4 = Return value
0 = Unknown

If you haven't worked with ADO before, here's something for the SQL Server
Northwind database to get you started:

use Win32::OLE qw (in);
use Win32::OLE::Variant;

$connstring = <<EOF;
    Provider=SQLOLEDB.1;
    Password=whatever;
    Persist Security Info=True;
    User ID=sa;
    Initial Catalog=Northwind;
EOF

# Get ADO Command Object
$cmd = new Win32::OLE("ADODB.Command");

# Specify that we'll be executing a stored procedure; not necessary, but
optimal.
$cmd->{CommandType} = 4;

# Name of the stored procedure
$cmd->{CommandText} = "CustOrdersOrders";

# Use Named Parameters so the Parameters-collections is filled automagically
$cmd->{NamedParameters} = 1;

# Associate ADO Command with a Connection; implicitly spawns an ADO
connection object
$cmd->{ActiveConnection} = $connstring;

# Refresh the parameters-collection
$cmd->Parameters->Refresh();

# We define @CustomerID stored proc. parameter to VINET
$cmd->Parameters('@CustomerID')->{Value} = 'VINET';

# Execute command
$rst = $cmd->Execute();

# Loop the results
until ($rst->{EOF}) {
    print "--\n";
    foreach $field (in ($rst->Fields)) {
        print $field->{Name}, "\t", $field->{Value}, "\n";
    }
    $rst->MoveNext();
}

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to