?
Solved

Backup with Async prograning "cmd.EndExecuteNonQuery(result)" is -1 although backup created?

Posted on 2014-03-20
1
Medium Priority
?
289 Views
Last Modified: 2014-08-17
            string connString = string.Format("Data Source=MY_SERVER;Initial Catalog=master;Integrated Security=True");
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connString);
            builder.AsynchronousProcessing = true;
            using (SqlConnection sqlConnection1 = new SqlConnection(builder.ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("BACKUP DATABASE [TEST_DB] TO  DISK = N'\\\\servername\\foldername\\backup.bak' WITH NOFORMAT, INIT,  NAME = N'Full_Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 100", sqlConnection1))
                {
                    sqlConnection1.Open();


                    IAsyncResult result = cmd.BeginExecuteNonQuery();



                    result.AsyncWaitHandle.WaitOne();



                    int  rs = cmd.EndExecuteNonQuery(result);
      }
            }

Open in new window


The "EndExecuteNonQuery(result)"  "rs"  is  -1 not 1

why? how can i know it's success?
0
Comment
Question by:center1010
[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
1 Comment
 
LVL 25

Accepted Solution

by:
apeter earned 2000 total points
ID: 39950260
EndExecuteNonQuery returns number of rows affected and here the case is it is taking a backup.

As long as you didn't had any error thrown, mean backup is success.  Also you can check whether the .bak file is created and its size is more than zero at the end if you want.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses

800 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