Skip to Content.
Sympa Menu

freetds - RE: [freetds] Perl and MS SQL

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Vecchio, Peppi" <PVecchio AT orangelake.com>
  • To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Perl and MS SQL
  • Date: Wed, 12 Mar 2003 08:27:33 -0500

Sure. It took me a while to discover the need for '$dbh->quote($string)' in
the INSERT statement. I'm using FreeTDS 5.6(?), MSSQL Server 7.0 and Red Hat
Linux 7.3. Works great for me.

######### Example only
#!/usr/bin/perl -Tw

use strict;
use DBI;

#There are many other security measures - Also, don't forget to use a
'username' and 'password' for the DB - Do Not use 'sa' and ''.

$ENV{'SYBASE'} = '/usr/local/freetds' unless $ENV{'SYBASE'};
my $dbh =
DBI->connect('dbi:Sybase:server=60.172.168.1;database=Employee-DB','sa','');
my $last_name = param("last_name");
my $first_name = param("first_name");
my $sth = $dbh->prepare("SELECT * FROM info WHERE last_name = '$last_name'
AND first_name = 'first_name'");

$sth->execute() or die $sth->errstr;
while (my @type = $sth->fetchrow_array()) {
print qq($type[0]/n);
print qq($type[1]/n);
}
$sth->finish();
$dbh->disconnect;



Peppi Vecchio | Web Developer
TECHNOLOGY SERVICES GROUP



-----Original Message-----
From: Peter Milburn [mailto:peterm AT sportodds.com]
Sent: Tuesday, March 11, 2003 5:03 PM
To: 'FreeTDS Development Group'
Subject: RE: [freetds] Perl and MS SQL


thanks heaps for the code.


Are you able to send some code that does a select query ?

Thanks

Pete

-----Original Message-----
From: Vecchio, Peppi [mailto:PVecchio AT orangelake.com]
Sent: Wednesday, 12 March 2003 8:41 AM
To: 'FreeTDS Development Group'
Subject: RE: [freetds] Perl and MS SQL



Here's some sample code:

$ENV{'SYBASE'} = '/usr/local/freetds' unless $ENV{'SYBASE'};
my $dbh =
DBI->connect('dbi:Sybase:server=172.1.162.3;database=Employee-DB','sa','');
my $last_name = param("last_name");
my $a1 = $dbh->quote( $last_name );
my $sql = qq/
INSERT INTO employee_info
( last_name) VALUES ( $a1 )
/;
my $rv = $dbh->do( $sql );

$dbh->disconnect;

Peppi Vecchio | Web Developer
TECHNOLOGY SERVICES GROUP



-----Original Message-----
From: Peter Milburn [mailto:peterm AT sportodds.com]
Sent: Tuesday, March 11, 2003 4:32 PM
To: Freetds (E-mail)
Subject: [freetds] Perl and MS SQL


Hi All,


We currently are using Freetds and PHP to connect to a MS SQL Server, Does
anyknow how to get Perl and Freetds to connect to a MS SQL server


Thanks,

Pete
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds




Archive powered by MHonArc 2.6.24.

Top of Page