Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Backup Sql databse

by dmsparts (Sexton)
on Feb 02, 2012 at 16:31 UTC ( #951482=note: print w/ replies, xml ) Need Help??


in reply to Re: Backup Sql databse
in thread Backup Sql databse

Hi, i think that this is the problem. however i can't work out how to use the suggestion on my script, i have done this,

#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use DBI; print "Content-type: text/html\n\n"; my $dbs = "DBI:ODBC:DRIVER={SQL Server};SERVER={dmssql01};DATABASE={sa +ge200_dmstestconversion}"; my ($username, $password) = ('user', 'passwd'); my $dbh = DBI->connect($dbs, $username, $password) or die "$DBI::errst +r\n"; my $sth = $dbh->prepare( 'backup database Sage200_DMSTestConversion to + DISK = \'d:\sage\sage200data\sagebackup2.bak\' ;') or die "Couldn't +prepare statement: " . $dbh->errstr; $sth->execute() or die "execute failed: " . $sth->errstr(); do { while (my @row = $sth->fetchrow_array()) { print "backing up,<br>"; print @row; } } while ($sth->{odbc_more_results}); my @error = $sth->err; print @error; $sth->finish(); $dbh->disconnect(); print "Backup Completed";
This still gives me the same output to screen and doesn't backup. Thanks


Comment on Re^2: Backup Sql databse
Download Code
Re^3: Backup Sql databse
by mje (Deacon) on Feb 02, 2012 at 19:38 UTC

    Take this out of CGI and just run it from the command line until you get it working. The backup command outputs print statements which are usually received via an error handler. Look at the script http://cpansearch.perl.org/src/MJEVANS/DBD-ODBC-1.34_2/examples/backup_restore.pl which I know works - you might want to comment out the restore first though. The main point is that any procedure you call has to run to completion and if nocount is off and the proc issues output the client end needs to read the output or the proc does not complete.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951482]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-09-02 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (18 votes), past polls