Solved

Connecting Perl to MS SQLserver

Posted on 2012-03-28
2
492 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
2 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Refresh Dev server with Production database 8 29
SQL Error - Query 6 26
Create snapshot on MSSQL 2012 3 20
Merge two rows in SQL 4 15
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

803 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