Hi Everyone,

I am trying to use the OLE method of connecting to an ADO connection in MS
SQL. I have copied working VBScript code and I am trying to convert it to
Perl. Any ideas on how to make this work?

If you know how to execute a stored procedure using Win32::ODBC->$sql (or
whatever) in a remote SQL database, I would be interested in seeing that as
well, but for the purposes of this script, it is important to stick to the
OLE method if possible (because VB programmers will probably be maintaining
this code and the OLE method appears to be a little closer to native code
for them).

Thanks in advance,

Garth

######## begin code ######################

use Win32::OLE;

$host = "PCName";

Win32::OLE::CreateObject("ADODB.Connection", $objConn) || die "CreateObject
Connection: $!; $^E";

Win32::OLE::CreateObject("ADODB.Command", $objCommand) || die "CreateObject
Command: $!; $^E";

Win32::OLE::CreateObject("ADODB.RecordSet", $objRS) || die "CreateObject
RecordSet: $!; $^E";

$objConn-> {ConnectionTimeout} = 120;

$objConn->open('Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=distributor;'.
        'PWD=distributor;Initial Catalog=ClientDistribution;Data
Source=GAATLITSQL01S') || die "ADO Open Error: $!; $^E";


$objCommand-> {CommandText} = "spWhichTYES";
$objCommand-> {CommandType} = 4;

$objCommand-> {ActiveConnection} = $objConn;

$objCommand->Parameters-> {Value} = $host;

$objRS = $objCommand->execute() || die "ADO execute spWhichTYES Error: $!;
$^E";

while(!$objRS->EOF()) { 
        $returned = $objRS->Fields('*')->Value; 
        write; # print them out 
        $objRS->MoveNext(); 
}

$objRS->close();                # shut down the recordset 

$objConn->close();      # close the data source 

exit;

################## end code ##########################

I am getting the error: "ADO Open Error: ;  at E:\Scripts\ADO.pl line 14."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to