Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Answer: What is the difference between ADO and ODBC ?

( #117713=categorized answer: print w/ replies, xml ) Need Help??

Q&A > database programming > What is the difference between ADO and ODBC ? contributed by jehuni

ADO is basically a high-level OO interface to various low-level OLEDB data providers. ODBC is another kind of low-level data provider, and if there is no native OLEDB provider for the type of database you use, but there is an ODBC one, you can always use the OLEDB provider for ODBC to bridge that gap.

IMHO, ADO is a much more flexible option than dealing directly with a data provider like ODBC, unless you really have the need to some sort of low-level optimization. Plus, for an MS database technology like Access, using a native OLEDB provider should be faster.

Since you can't set up a DSN, I believe that something like this will work for you:

use strict; use Win32::OLE; my $provider = 'Microsoft.Jet.OLEDB.4.0'; my $dir = 'c:\perl\cgi-bin'; my $dbase = 'mydb.mdb'; my $user = ''; #use if needed my $password = ''; #use if needed my $connStr = "Provider=$provider;Data Source=$dir\\$dbase;User ID=$us +er;Password=$password;"; my $conn = Win32::OLE->new('ADODB.Connection') or die("Could not creat +e Connection: $!"); $conn->Open($connStr);


Comment on Answer: What is the difference between ADO and ODBC ?
Download Code
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-11-30 00:23 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (754 votes), past polls