in reply to Re: Connection to DataBase
in thread Connection to DataBase
You can use DBD::ADO or DBD::ODBC to connect to SQL Server 2008 databases, if you use DBD::ODBC you may google for "DSN less connection", this is what you need. Using BDB::ADO the connection should look like:
my $userid = q{}; my $password = q{}; my $strCnn = "Provider=SQLOLEDB; Data Source=$Servername; Initial +Catalog=$Tablename; Integrated Security=SSPI;"; $dbh = DBI->connect( "dbi:ADO:$strCnn", $userid, $password, { Rais +eError => 1, AutoCommit => 0 } ) or croak "Cannot connect: $DBI::errstr";
but beware, there is a problem: SQLOLEDB may truncate inserted strings. Look at the docs of DBD::ADO.
If you use DBD::ODBC the connection should look like:
my $data_source = qq/dbi:ODBC:driver={SQL Server};Server=$Serverna +me;database=$DataBaseName;Regional=No;/; my $user = q//; my $password = q//; $dbh = DBI->connect($data_source, $user, $password) or die "Can't connect to $data_source: $DBI::errstr";
Hope that helps.
|
|---|