Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to connect to the sql server database of remote machine and fetch some information using Perl Script.
PERL
use DBI;
my $dsn = 'DBI:ODBC:Driver={SQL Server}';
my $host = 'MyPC\SQL';
my $database = 'databasename';
my $user = 'username';
my $auth = 'password';
my $dbh = DBI->connect("$dsn;Server=$host;Database=$database;$user;$auth") || die "Database connection not made:: $DBI::errstr";

i have modified this as follows, inorder to connect to the sql server of remote machine

PERL
use DBI;
    my $dsn = 'DBI:ODBC:Driver={SQL Server}';
    my $host = 'MyPC\SQL';
    my $database = 'databasename';
    my $user = 'username';
    my $auth = 'password';
    my $hostIP='10.1.8.95'
    my $dbh = DBI->connect("$dsn;Server=$host;Database=$database;host=$hostIP;$user;$auth") ||die "Database connection not made:: $DBI::errstr";


but i am getting an error saying that connection string is wrong.
can anyone please help me...
Posted

1 solution

Hello,

Please Change your connect call as shown below.
PERL
my $dbh = DBI->connect("$dsn;Server=$hostIP;Database=$database;",$user,$auth) ||die "Database connection not made:: $DBI::errstr";

More help can be found in this document.

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900