Perl 创建一个新的 ODBC 数据源

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

 use Cwd;
 use Win32::ODBC;

 $DriverType = "Microsoft Access Driver (*.mdb)";
 $DSN = "Email Contacts";
 $Description = "Description=Email List and Contact Information";
 $DataBase = "EmailContacts.mdb";
 $dir = cwd();
 if (Win32::ODBC::ConfigDSN(ODBC_ADD_DSN,
                            $DriverType,
                            ("DSN=$DSN",
                            $Description,
                            "DBQ=$dir\\$DataBase",
                            "DEFAULTDIR=$dir",
                            "UID=", "PWD="))){
    print "Successful configuration of $DSN!\n";
 }
 else{
    print "Error Creating $DSN\n";
    Win32::ODBC::DumpError();
    die;
 }
 my $myDb = Win32::ODBC->new($DSN);
 my $connection;
 if (! $myDb){
    print "Failed to Connect $DSN\n";
    Win32::ODBC::DumpError();
    die;
 }else {
    $connection = $myDb->Connection();
    print "Successful Connection $connection, $DSN\n";
 }
 $myDb->Close();