Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

(ar0n) Re: sql connection

by ar0n (Priest)
on Nov 26, 2001 at 23:01 UTC ( [id://127598]=note: print w/replies, xml ) Need Help??


in reply to sql connection

  1. The module's name is Win32::OLE (note capitalization).
  2. Are you including the module for use, with use?

[ ar0n ]

Replies are listed 'Best First'.
Re: (ar0n) Re: sql connection
by wang2173 (Initiate) on Nov 27, 2001 at 00:04 UTC
    Thanks much, use is what I missed, now I went further and encountered another problem, I use Recordset to get table values, but program is terminated at $rs->RecordCount. my $rs = Win32::OLE->new('ADODB.Recordset'); $rs->Open("Select * from $SQLTABLE", $conn); if ($rs->RecordCount > 0) {...} Can you point out where might be wrong? -- PC
      You might want to try posting your code inside <code> </code> tags. It'll look like this:
      $rs->RecordCount. my $rs = Win32::OLE->new('ADODB.Recordset'); $rs->Open("Select * from $SQLTABLE", $conn); if ($rs->RecordCount > 0) {...}
      It's a little easier to read and thus a little bit more likely to get a good response to your question. Also, <code> tags allow others to easily download your code. You be amazed at how many fellow members of the Monastery will actually try out your code in order to better help you.

      You might also want to check out Writeup Formatting Tips.

      Cheers!

      Brent

      Not all cursor types can return a RecordCount, including the default ForwardOnly cursor type. Since you aren't explicitly specifying a cursor type, you're getting the default, in which case RecordCount will return -1.

      If you truly need the RecordCount, use either a Static or Keyset cursor. However, a Static cursor will load the entire recordset into memory, so you might want to avoid that. A Keyset on the other hand, only loads in the primary keys, and then uses that to cache subsets of the recordset. Of course, if someone adds a row in the meanwhile, it won't be available. Plus, there's extra overhead involved in the multiple roundtrips to update the cache as you navigate the recordset

      My guess is that what you really want to know is whether or not the recordset is empty. Try:

      unless ( $rs->{EOF} && $rs->{BOF} ) { ... }
      That will tell you whether or not it's empty, but can still take advantage of the efficiency of a ForwardOnly cursor.

      -jehuni

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found