Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Connecting Perl to MS SQLserver

Posted on 2012-03-28
2
Medium Priority
?
499 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 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

916 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