Perl에 새로 입문되었습니다. DBI가 SQL 서버 2008 DB와 통신하도록하는 데 문제가 있습니다.Perl DBI SQL 서버 연결 문제
ODBC를 직접 사용하려고 할 때 SQL Servereveb에 연결하려고하면 다음과 같은 오류가 발생합니다.
나는 펄에 새로운 오전 누군가가 ... 도와 주실 래요 감사
install_driver (MSSQL)는 실패 : "MSSQL을 클래스 :: DBI ::"패키지를 통해 객체 메소드 "set_sql"를 찾을 수 없습니다 C에서 : /Perl/lib/DBD/MSSQL.pm 라인 79 컴파일에 실패 (평가 19) C에서 필요합니다 /Perl/site/lib/DBI.pm : 744 라인 3.
use strict;
use warnings;
use diagnostics;
use Class::DBI::Loader;
use DBI;
use File::Glob ':glob';
my $DBUserName = "*******";
my $DBPassword = "*******";
my $DBName = "dbi:MSSQL:uat-dbserver1";
my $dbh = "";
my $sqlStatement = "";
my $sqlCmd = "";
my @EasySetTableNames =();
$dbh = DBI->connect($DBName, $DBUserName, $DBPassword,
{ PrintError => 0, AutoCommit => 0})
|| die "Database connection creation failed: $DBI::errstr\n";
$sqlStatement = "SELECT * from tableA ";
$sqlCmd = $dbh->prepare($sqlStatement);
$sqlCmd->execute();
@EasySetTableNames = @{$dbh->selectcol_arrayref($sqlStatement)};
print "hi";
및 ODBC를 통해
#!/usr/bin/perl -w
use strict;
use DBI;
# Replace datasource_name with the name of your data source.
# Replace database_username and database_password
# with the SQL Server database username and password.
my $data_source = "dbi:MSSQL:test";
my $user = "test";
my $password = "test";
# Connect to the data source and get a handle for that connection.
my $dbh = DBI->connect($data_source, $user, $password)
or die "Can't connect to $data_source: $DBI::errstr";
# This query generates a result set with one record in it.
my $sql = "SELECT 1 AS test_col";
# Prepare the statement.
my $sth = $dbh->prepare($sql)
or die "Can't prepare statement: $DBI::errstr";
# Execute the statement.
$sth->execute();
# Print the column name.
print "$sth->{NAME}->[0]\n";
# Fetch and display the result set value.
while (my @row = $sth->fetchrow_array) {
print "@row\n";
}
# Disconnect the database from the database handle.
$dbh->disconnect;
제공 할 수있는 도움을 주시면 감사하겠습니다.
Re "SQL Server를 직접 지원합니까?" 그것은 개별 DBD에 달렸습니다. 대부분의 ODBC에 대해 몰라요. DBD :: ODBC는 명백한 예외입니다. – ikegami
흠, 당신이 사용하는 DBD :: MSSQL은 CPAN에 존재하지 않습니다! – ikegami
'Class :: DBI :: MSSQL'에 대한 문서는 후드에서'DBD :: ODBC'를 사용하고 있음을 나타냅니다. – tjd