Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Perl OLE32 MSSQL SELECT dateadd function results in “Cursor type changed” error

by dasgar (Deacon)
on Dec 09, 2013 at 06:24 UTC ( #1066254=note: print w/ replies, xml ) Need Help??


in reply to Perl OLE32 MSSQL SELECT dateadd function results in “Cursor type changed” error

If you look at the Description section of Win32::OLE's documentation, the first two sentences are: "This module provides an interface to OLE Automation from Perl. OLE Automation brings VisualBasic like scripting capabilities and offers powerful extensibility and the ability to control many Win32 applications from Perl scripts."

Basically, that means you're not going to be able to run queries directly against a database using that module. Instead, it would allow you to control Windows applications (such as Microsoft Office products). If you want to run queries directly against a database, you might want to look into Win32::ODBC and/or DBD::ODBC.

Although it sounds like you're not allowed to install other modules, that may not be an issue. Here's info on 3 popular Perl distributions for Windows:

Also, I think there's more to your code than what you posted. In your posted code, it looks like $conn and $rs are objects, but those objects are not defined or created. And your posted code has an unfinished if statement. When I try running your code (with the if statement commented out), it bails on the $conn->open; line with the following error message: Can't call method "open" on unblessed reference at test.pl line 3.

In other words, your posted code doesn't reproduce the error messages that you say that you're seeing. Perhaps if you can share more information on your limitations and what you're trying to do or maybe some reduced code that can reproduce your error message, others might be able to help you out more.


Comment on Re: Perl OLE32 MSSQL SELECT dateadd function results in “Cursor type changed” error
Select or Download Code
Re^2: Perl OLE32 MSSQL SELECT dateadd function results in “Cursor type changed” error
by newbieperlperson (Acolyte) on Dec 09, 2013 at 06:42 UTC
    Hi there,

    Thank you for taking the time to look into this.

    I have been using the WIN32:OLE to run select, update SQL statements against a mssql DB with no issues at all.

    Here is a different CPAN where it shows the ADO object under WIN32:OLE is used to execute SQL

    http://search.cpan.org/dist/Win32-OLE/lib/Win32/OLE/TPJ.pod

    For some reason it is not working for this one statement which is the odd thing.

    I will be in the office tmw and will update the code to include the connection string. Thanks,

    AJ

      I recommended you take a look at DBD::ADO, it does all that Win32::OLE ADO stuff for you in familiar DBI style ... so you don't have to suffer the maze of OLE :)
      #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd pp /; use DBI(); Main( @ARGV ); exit( 0 ); sub Main { my $att = {qw/RaiseError 1/}; my $user = my $pass = undef; my $dbh = DBI->connect("dbi:ADO:$dsn", $usr, $pwd, $att ) ; $dbh->trace(3); my $sth = $dbh->prepare( $mssql_select ); dd( $sth->execute ); dd( $sth->fetchall_arrayref ); }

      See also Tutorials->Database Programming->DBI recipes

        Thanks for the tip, unfortunately I am not able to get DBD installed on this particular environment which is why I am having to use OLE ):
Re^2: Perl OLE32 MSSQL SELECT dateadd function results in “Cursor type changed” error
by Anonymous Monk on Dec 09, 2013 at 07:57 UTC

    Basically, that means you're not going to be able to run queries directly against a database using that module. Instead, it would allow you to control Windows applications ... I don't know much about Win32 and OLE

    Sorry dasgar, but on previous occasion you've said (or demonstrated) you don't win32 much, so if you know you don't know, resist the temptation please

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1066254]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (14)
As of 2014-07-22 20:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (127 votes), past polls