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

Re: Connection to a MSSQL Database

by simon.proctor (Vicar)
on Jan 13, 2002 at 19:41 UTC ( #138432=note: print w/replies, xml ) Need Help??

in reply to Connection to a MSSQL Database

If you can you should stick to the ODBC driver under the DBI as much as possible. Otherwise I would recommend that you use the Win32::OLE module and create recordsets to the database.

The OLE method should only be a fall back position (though it can't always be helped) as your function calls are no longer DBI based. Hence this affects your portability.

Two examples of OLE code can be found in the following:

Or heres snippet from some recent code I have been using. This code selects information from a Memo field.
use constant DATA => 'driver=Microsoft Access Driver (*.mdb); +dbq=data.mdb'; my $db_connection = new Win32::OLE('ADODB.Connection'); my $rs = new Win32::OLE("ADODB.Recordset"); # Connect to the database and tie the recordset object to # the database. $db_connection->Open(DATA); # Set the connection doohickey # $rs->CursorLocation(adUseClient); my $sql = "select from MYTABLE as c;"; $rs->Open($sql, $db_connection, adOpenKeySet); if($rs->BOF()) { return; } my $data = $rs->getrows(); return unless defined($data->[0][0]); return $data->[0][0];

Ok thats with access but it should be the same for MSSQL

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2019-12-13 03:10 GMT
Find Nodes?
    Voting Booth?

    No recent polls found