I'm doing backup of database through code:
using (var connection = new SqlConnection(_connectionString))
{
var query = String.Format("BACKUP DATABASE [{0}] TO DISK='{1}'", databaseName, fileName);
using (var command = new SqlCommand(query, connection))
{
connection.Open();
command.ExecuteNonQuery();
}
}
The return value od ExecuteNonQuery()
is useless because I get as result -1.
Is there any other way do detect when the backup is done?