siva rajesh
Answered On : Mar 17th, 2006
Dear folks, there is a module in perl named DBI - Database independent interface which will be used to connect to any database by using same code. Along with DBI we should use database specific module here it is SQL server. for MSaccess it is DBD::ODBC, for MySQL it is DBD::mysql driver, for integrating oracle with perl use DBD::oracle driver is used. IIy for SQL server there are avilabale many custom defined ppm( perl package manager) like Win32::ODBC, mssql::oleDB etc.so, together with DBI, mssql::oleDB we can access SQL server database from perl. the commands to access database is same for any database. for furhter help needed, u can mail me-Rajesh

1 User has rated as useful.
Login to rate this answer.
madhu
Answered On : Nov 17th, 2006
hi,
In perl we have DBI module to connect to any database.
step1: we need to intialise the DBI module
use DBI;
step2 : connect to database using DBI module which reutrns database handle
$dh = DBI->connect("dbi:mysql:database=DBname","username","password");
step3 : to rertive data from database use select query
$sth = $dh->prepare("select name,symbol from table");
$sth->execute();
while(@row = $sth->fetchrow_array()){
print "name =$row[0],symbol = $row[1];
}
$dh->disconnect();

1 User has rated as useful.
Login to rate this answer.
Rob
Answered On : Apr 9th, 2007
The other trick is to use http://www.freetds.org/ for your sybase driver (M$SQL is just an old version of sybase that has been heavily modified). Then standard DBI calls work. Here is a program to login to an SQL server and print success if login is ok:
use DBI;
use DBD::FreeTDS;
$opt_u = "USERNAME";
$opt_p = "PASSWORD";
$opt_s = "SERVERNAME:1433";
$dbh = DBI->connect("dbi:FreeTDS:server=$opt_s", $opt_u, $opt_p);
$error = $DBI::errstr;
if (defined($dbh)) {
# SUCCESS
print "Login goodn";
} else {
# ERROR
print "$errorn";
}
Login to rate this answer.