For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2004 > SQL2000









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SQL2000
mgoland@optonline.net

2004-10-18, 8:55 pm

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 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 connection to MySQL server during query at C:\temp\perl\te.pl line 21


Jenda Krynicky

2004-10-18, 8:55 pm

Subject: 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

Mark Goland

2004-10-18, 8:55 pm

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


> 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>
>
>
>



Mark Goland

2004-10-18, 8:55 pm


----- 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

[color=darkred]
>
>
>
> --
> 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>
>
>
>



Jenda Krynicky

2004-10-18, 8:55 pm

From: 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

ragner4u@gmail.com

2004-10-19, 3:57 am

$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

Bob Showalter

2004-10-19, 8:58 am

Mark 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.
mgoland@optonline.net

2004-10-19, 3:55 pm



----- 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>
>
>
>


Jenda Krynicky

2004-10-19, 3:55 pm

From: 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

Emmon Simbo

2004-10-25, 8:55 am

Mark

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com