Re: Not able to connect to Mysql Database using ODBC



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
.



Relevant Pages

  • Re: Cannot see / enumerate DSN ODBC using perl in Windows
    ... I've moved my working W2k3 Activestate Perl 5.8 system to another ... ODBC system DSNs. ... Are you saying that when you logon to your 2003 box as user X you can run up the odbc administrator and see a SYSTEM DSN, you can run another app that uses that SYSTEM DSN but Perl's data_sources run as the same user does not return the DSN? ...
    (perl.dbi.users)
  • Re: Word 2000/2002 - Proper Mail Merge steps for ODBC?
    ... > Document to connect to a Secured Access Database, ... using the ODBC provider for OLEDB. ... they have a .dsn extension. ... directly (in the Open/Select Data Source dialog box). ...
    (microsoft.public.word.mailmerge.fields)
  • Re: ODBC connection to mdb for MacIntosh
    ... >>> Microsoft Access does not exist for the Mac. ... In order to use ODBC ... >>> the data tables (the .mdb file) has to reside on a Windows computer that ... As long as the computer has ODBC drivers for an Access ...
    (microsoft.public.mac.otherproducts)
  • Re: ODBC connection to mdb for MacIntosh
    ... As long as the computer has ODBC drivers for an Access database, it does NOT have to have Access installed. ... Office 98 and 2001 it was possible to control several different types of databases directly on a single Mac without having the application on the computer. ... No, you can not put the mdb file on a mac and connect to MS Access via ODBC because MS Access only runs in windows, not on a Mac. ... If you search Google on this topic about 2 years ago there was a complete thread in the Excel for Mac newsgroup about ODBC drivers. ...
    (microsoft.public.mac.otherproducts)
  • Re: Silly ODBC Connection problem
    ... it seems to me this must be done interactively on each client--either that or use the magical "DSN-less" connection. ... It's been 11 or years or so since I wrote about ODBC so it's getting kinda fuzzy. ... 556-9205 (Pacific time) ... > created a System DSN named "MyDSN" in the ODBC Administrator tool. ...
    (microsoft.public.dotnet.framework.adonet)