Not able to connect to Mysql Database using ODBC
am 30.11.2006 19:59:05 von Sriman.Narayana
------_=_NextPart_001_01C714B1.765396E8
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hi,
I am new to perl programming. Installed mysql,perl,mysql odbc drivers
in my machine. Following is my code, its not working. I googled it but
no use :(
use DBI::W32ODBC;
$dbh=3D DBI->connect("DBI:W32ODBC:TestMyDSN","rootuser","rootuserpwd ") =
||
die "Got error $DBI::errstr when connecting to $dsn\n";
error msg:
Error connecting to =
DBI:W32ODBC:TestMyDSN;UID=3Drootuser;PWD=3Drootuserpwd:
[911] []
"[Microsoft][ODBC Driver Manager] Data source name not found and no
default dri
ver specified"
Got error when connecting to
is there any thing missing in my machine? Any idea?
Thanks in advance.
Thanks & Regards,
Sri
------_=_NextPart_001_01C714B1.765396E8--
Re: Not able to connect to Mysql Database using ODBC
am 01.12.2006 10:03:55 von Martin.Evans
Narayana, Sriman Export License Required - US UTCHQ wrote:
> Hi,
>
> I am new to perl programming. Installed mysql,perl,mysql odbc drivers
> in my machine. Following is my code, its not working. I googled it but
> no use :(
I have not used MySQL on Windows myself but the normal way to access
MySQL from Perl is using DBD::mysql - perhaps that is not available for
Windows. If you need to use ODBC then there are two DBI drivers to
choose from DBD::ODBC and DBD::W32ODBC. I've never used DBD:W32ODBC but
then I've not used Perl and ODBC on Windows much.
> use DBI::W32ODBC;
> $dbh= DBI->connect("DBI:W32ODBC:TestMyDSN","rootuser","rootuserpwd ") ||
> die "Got error $DBI::errstr when connecting to $dsn\n";
>
> error msg:
> Error connecting to DBI:W32ODBC:TestMyDSN;UID=rootuser;PWD=rootuserpwd:
> [911] []
> "[Microsoft][ODBC Driver Manager] Data source name not found and no
> default dri
> ver specified"
> Got error when connecting to
This has not even reached your ODBC driver. The driver manager cannot
find DSN TestMyDSN.
> is there any thing missing in my machine? Any idea?
> Thanks in advance.
>
> Thanks & Regards,
> Sri
>
Have you created a DSN called TestMyDSN in the ODBC Administrator in
Control Panel? If you have, is it a user DSN or a system DSN? User DSNs
are only visible to the user who created them e.g. you log on as Sri,
create a user DSN then attempt to use it under a web server not running
as Sri (that won't work, you'd need a system DSN in that case).
There are also File DSN, but I'm assuming you are not using one of those.
Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com
Re: Not able to connect to Mysql Database using ODBC
am 01.12.2006 10:47:20 von John1
Apologies for the previous html.
On 30 Nov 2006 at 13:59, Also Sprach Narayana, Srimanrt License:
> I am new to perl programming. Installed mysql,perl,mysql odbc
> drivers
> in my machine. Following is my code, its not working. I googled it but
> no use :(
Why use odbc?
Get the latest activestate perl and using the package manager get the latest DBI and
DBD-mysql packages.
Here's some code that will connect to your mysql db (not tested):
#! /usr/bin/perl -w
use strict;
use diagnostics;
use DBI;
eval {
my $dbh = DBI-
>connect('DBI:mysql:database=db_name;host=localhost;port=33
06',
'username',
'password',
{'RaiseError' => 1,
'PrintError' => 0,
'AutoCommit' => 0} );
}; # eval
( $@ ) {
for my $dbh ( @dbhs ) {
$dbh->rollback if $dbh;
}
die $@;
}