473,480 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

can i connect with mysql and mssql in one perl program

2 New Member
i have predifined mysql connections now i want to use mssql connection for example subroutine.i tried but failed. i am thankful if any one could help this out..thanks in advance


Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. require Exporter;
  3. use C4::Context;
  4. use DBI;
  5. use DBD::ODBC;
  6. use CGI;
  7. sub fixEthnicity($) {
  8.  
  9.     my $ethnicity = shift;
  10.     my $dbh = C4::Context->dbh;
  11.     my $sth=$dbh->prepare("Select name from ethnicity where code = ?");
  12.     $sth->execute($ethnicity);
  13.     my $data=$sth->fetchrow_hashref;
  14.     $sth->finish;
  15.     return $data->{'name'};
  16. }
  17. sub example {
  18.  
  19. # CONFIG VARIABLES
  20. my $platform = "ODBC";
  21. my $database = "xdclient";
  22. my $host = "localhost";
  23. my $port = "3000";
  24. my $tablename = "dbo.User_login";
  25. my $db_user     = "sa";
  26. my $db_pass     = "ablogics";
  27. my $dsn_name    = 'DBI:ODBC:xdclient';
  28. my $h = DBI->connect($dsn_name, $db_user, $db_pass);
  29. my $sth=$h->prepare("SELECT password FROM dbo.User_login WHERE #username = 'satya'");
  30. # Execute the query
  31. $sth->execute() or die "Couldn't execute statement:
  32. $DBI::errstr; stopped";
  33. # Fetch each row and print it
  34. while ( my @row = $sth->fetchrow_array() )
  35. {
  36. return $row[0];
  37. }
  38. }
  39.  
  40.  
Sep 3 '12 #1
1 1737
RonB
589 Recognized Expert Moderator Contributor
Saying "i tried but failed" doesn't tell us anything.

1) In what way did it fail?

2) What error message did you receive?

3) What does the C4::Context module do and what error handling does it provide?
Sep 4 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2467
by: varala_kanth | last post by:
hello friends, iam new bie i run the perl program with in command mode with this following command perl <filename>.pl
1
4637
by: pratchaya | last post by:
What the best language code to connect MySQL --> C , C++ , php,VB,Delphi ? about ---- Speed ---- Stable ---- Security Can anyone compare C , C++ , php4,php5 ,vb ,delphi to connect to...
3
4105
by: sir.linying | last post by:
My php script is to call perl scipt which makes use of Spreadsheet::ParseExcel module to parse Excel file. I am able to launch php script from command line so that perl script can run and properly...
1
2942
by: shun | last post by:
Hello, I need an sample program to connect mysql server by using odbc. thanks in advance
3
3392
by: Uncle Sam | last post by:
Hi, Please confirm.. is it possible to connect to MSSQL server by executing a shell script on HP-UX (UNIX) platform. Regards, Uncle Sam
0
1507
by: brakesh | last post by:
Hi, I am trying to call a perl program (that connects a webserver database) from a php program via a webbrowser. For example : http://development.noaa.gov/test_exec.php?dataid=8313. The...
1
2698
by: Akino877 | last post by:
Hello, I have a small Perl program : #!/usr/bin/perl -w use DBI; use Mysql; $host = ""; $database = ""; $user = "root";
3
7345
by: likigoldenstar | last post by:
Hi, I have some problem in developing program using PHP. I 'll explain my platforms: I use appserv-win32-2.5.9 as a app server. In the server, mysql client version is 5.0.37 Problems:
1
1261
parajaganesh
by: parajaganesh | last post by:
I need to access mysql using perl in linux. It requires mysql.pm. I tried to install it in linux. /usr/bin/perl -MCPAN -e 'install "DBD::mysql"' It shows the following error... .. .. ..
1
1659
by: akshay mokhalga | last post by:
I have to connect my database Mysql to my C program how can I do this???
0
7048
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7091
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6743
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5344
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.