Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Connecting Perl to MS SQLserver

Posted on 2012-03-28
2
Medium Priority
?
498 Views
Last Modified: 2012-04-13
Hi,
 
i need a working example step by step how to connect Perl to MS SQLSERVER

regards,
0
Comment
Question by:zakwithu2012
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 1000 total points
ID: 37776067
0
 

Author Comment

by:zakwithu2012
ID: 37781098
Thank you for the links...

Can anybody tell me what is wrong in my below code:

#!/usr/bin/perl 
use DBI;
use strict;
use warnings;

my $db_instance = "HIPCCMGMT";
my $db_name = "CDR_CUCM7_1_5";
my $db_user = "sa";
my $db_pass = 'MyPassword'; 
my $dbh = DBI->connect("DBI:ODBC:Driver={SQL Server};Server=$db_instance;Database=$db_name;UID=$db_user;PWD=$db_pass") 
or die("\n\nCONNECT ERROR:\n\n$DBI::errstr");

my %hash = (             
1   =>  "A",             
2   =>  "13"            
);  

my @keys = keys %hash;  
my @values = values %hash;  
my $sth = $dbh->prepare("INSERT INTO DevicesData(DeviceName, DataValue) VALUES (?,?);");  
$sth->execute_array({},\@keys, \@values); 
$dbh->disconnect;

Open in new window


I'm getting this error:
C:\>perl test.pl
DBD::ODBC::st execute_array failed: executing 2 generated 1 errors at test.pl li
ne 23.

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Six Sigma Control Plans

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question