Code Comments
Programming Forum and web based access to our favorite programming groups.Hi all,
Not sure if this is the right list to ask this question but this is the best
list to get answares so I am going to give it a shot. I am trying to connec
t to SQL2000 server from a winXP box. I keep on failing with same error, any
help would be apreciated
#!PERl
use warnings;
use strict;
use Net::MySQL;
use DBI;
$|=1;
my $user='xxx';
my $password = '....';
my $database = "nnsdata_ptest";
my $hostname='somehost.com;
my $port = '1444';
my $dsn = "host=$hostname;port=$port";
my $dbh = DBI->connect("DBI:mysql:$dsn", $user, $password);
error:
main::count() called too early to check prototype at C:\temp\perl\te.pl line
71.
DBI connect('host=somehost.com;port=1444','username',...) failed: Lost conne
ction to MySQL server during query at C:\temp\perl\te.pl line 21
Post Follow-up to this messageSubject: SQL2000
> Hi all,
>
> Not sure if this is the right list to ask this question but this is
> the best list to get answares so I am going to give it a shot. I am
> trying to connect to SQL2000 server from a winXP box. I keep on
> failing with same error, any help would be apreciate
> d
>
> #!PERl
> use warnings;
> use strict;
> use Net::MySQL;
I thought you said SQL2000 and meant Microsoft SQL Server 2000!
> use DBI;
> $|=1;
>
>
> my $user='xxx';
> my $password = '....';
> my $database = "nnsdata_ptest";
> my $hostname='somehost.com;
> my $port = '1444';
>
>
> my $dsn = "host=$hostname;port=$port";
> my $dbh = DBI->connect("DBI:mysql:$dsn", $user, $password);
Again I thought you meant MS SQL Server 2000, not mysql.
That's a completely different and totally incompatible database!
You want to use DBD::ODBC, not DBD::mysql
Try:
my $DSN = "driver=SQL Server;Server=$hostname;Database=$databa
se';
my $dbh = DBI->connect("DBI:ODBC:$dsn", $user, $password);
HTH, Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
Post Follow-up to this messageJenda,
Thanks you are correct as usual. I do need to connect to MS SQL Server.
DB Stuff is a new task for me. Are there ODBC Drivers for Unix servers ?? Or
Alternative ways of accessing MS SQL from Unix servers ??
----- Original Message -----
From: "Jenda Krynicky" <Jenda@Krynicky.cz>
To: <beginners@perl.org>
Sent: Monday, October 18, 2004 6:24 PM
Subject: Re: SQL2000
> Subject: SQL2000
>
> I thought you said SQL2000 and meant Microsoft SQL Server 2000!
>
>
> Again I thought you meant MS SQL Server 2000, not mysql.
> That's a completely different and totally incompatible database!
>
> You want to use DBD::ODBC, not DBD::mysql
>
> Try:
>
> my $DSN = "driver=SQL Server;Server=$hostname;Database=$databa
se';
> my $dbh = DBI->connect("DBI:ODBC:$dsn", $user, $password);
>
> HTH, Jenda
> ===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
> When it comes to wine, women and song, wizards are allowed
> to get drunk and croon as much as they like.
> -- Terry Pratchett in Sourcery
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
Post Follow-up to this message
----- Original Message -----
From: "Mark Goland" <mgoland@optonline.net>
To: "Jenda Krynicky" <Jenda@Krynicky.cz>; <beginners@perl.org>
Sent: Monday, October 18, 2004 6:33 PM
Subject: Re: SQL2000
> Jenda,
> Thanks you are correct as usual. I do need to connect to MS SQL
Server.
> DB Stuff is a new task for me. Are there ODBC Drivers for Unix servers ??
Or
> Alternative ways of accessing MS SQL from Unix servers ??
> ----- Original Message -----
> From: "Jenda Krynicky" <Jenda@Krynicky.cz>
> To: <beginners@perl.org>
> Sent: Monday, October 18, 2004 6:24 PM
> Subject: Re: SQL2000
>
>
Hmm Still fails, now I get :
main::count() called too early to check prototype at C:\temp\perl\te.pl line
64.
DBI connect('driver=SQL
Server;Server=mysite.com;Database=nnsdata_ptest','username',...) failed: at
C:\t
emp\perl\te.pl line 24
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
Post Follow-up to this messageFrom: Mark Goland <mgoland@optonline.net>
> Hmm Still fails, now I get :
> main::count() called too early to check prototype at
> C:\temp\perl\te.pl line 64. DBI connect('driver=SQL
> Server;Server=mysite.com;Database=nnsdata_ptest','username',...)
> failed: at C:\t emp\perl\te.pl line 24
Strange. Could you resend the whole test script?
Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
Post Follow-up to this message$dsn="DBI:whateverurusing:DatabaseName" connecting is done this way ... $dbh=DBI->connect($dsn,$user,$password); Atleast thats the way it works ;) ... Give it a try
Post Follow-up to this messageMark Goland wrote: ... > Are there ODBC Drivers for Unix servers ?? Yes. I've not used any personally. > Or Alternative ways of accessing MS SQL from Unix > servers ?? I use DBD::Proxy and DBI::ProxyServer for this. Works great.
Post Follow-up to this message
----- Original Message -----
From: Jenda Krynicky <Jenda@Krynicky.cz>
Date: Monday, October 18, 2004 6:52 pm
Subject: Re: SQL2000
> From: Mark Goland <mgoland@optonline.net>
> give it
> Server;Server=$hostname;Database=$databa
se';> > > my $dbh = DBI-
>
> Strange. Could you resend the whole test script?
Sure,
While looking at my code, looks like its trying to connect to default port.
I am unable to get it to connect to my port [ 1444 ], here is the code
#!PERl
use warnings;
use strict;
$|=1;
use DBI;
my $user='username';
my $password = ''pwd';
my $database = "nnsdata_ptest";
my $hostname='myhost.com';
my $port = '1444';
my $dsn = "driver=SQL Server;Server=$hostname;Database=$databa
se;Port=$port"
;
my $dbh = DBI->connect("DBI:ODBC:$dsn", $user, $password);
>
> Jenda
> ===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
> When it comes to wine, women and song, wizards are allowed
> to get drunk and croon as much as they like.
> -- Terry Pratchett in Sourcery
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
Post Follow-up to this messageFrom: mgoland@optonline.net
> Sure,
> While looking at my code, looks like its trying to connect to
> default port. I am unable to get it to connect to my port [ 1444 ],
> here is the code
>
> #!PERl
> use warnings;
> use strict;
> $|=1;
> use DBI;
>
> my $user='username';
> my $password = ''pwd';
> my $database = "nnsdata_ptest";
> my $hostname='myhost.com';
> my $port = '1444';
>
> my $dsn = "driver=SQL
> Server;Server=$hostname;Database=$databa
se;Port=$port"; my $dbh =
> DBI->connect("DBI:ODBC:$dsn", $user, $password);
I think you are right. It seems to be ignoring the Port since if I
change the $hostname, $database, $user and $password I can connect to
my MS SQL even though it's on the default prompt.
Seems you will have to create a server alias via
Start\Programs\Microsoft SQL Server\Client Network Utility
There you can specify the port.
You would then use the alias you create instead of the myhost.com in
$hostname.
Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
Post Follow-up to this messageMark To answer your questions, there are ODBC drivers available from www.openlinksw.com that pretty much satisfy your requirements to a T. Secondly, a good resource for understanding how to get your connection going with Perl and ODBC to MySQL, or any other database, can be found at www.iodbc.org. Regards Emmon Simbo Jenda@Krynicky.cz (Jenda Krynicky) wrote in message news:<417567F9.21605.19EBEC82@localhost >... > From: mgoland@optonline.net > > I think you are right. It seems to be ignoring the Port since if I > change the $hostname, $database, $user and $password I can connect to > my MS SQL even though it's on the default prompt. > > Seems you will have to create a server alias via > Start\Programs\Microsoft SQL Server\Client Network Utility > > There you can specify the port. > > You would then use the alias you create instead of the myhost.com in > $hostname. > > Jenda > ===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz ===== > When it comes to wine, women and song, wizards are allowed > to get drunk and croon as much as they like. > -- Terry Pratchett in Sourcery
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.