Solved

Connecting Perl to MS SQLserver

Posted on 2012-03-28
2
485 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Need Counts 11 43
c# code 19 61
Powershell SMO script not working. 18 102
SQL Query for Periods 3 12
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now