I am having a problem when trying to do restore against a database using c#. It gives me timeout error in c# but works in SQL server management Studio. I've been googling around, and no luck so far fixing this problem. Also the similar problem here does not apply to my case...
the sql server version is 2008R2 version 10.50
Things ive tried:
increase connection timeout
increase commandTimeout
no luck on either
Here is the query:
DECLARE @ResultCode INT
EXEC @ResultCode = [master].[dbo].[xp_ss_restore] @database = 'KbbVehicle',@filename =
'\P02W02ETLDZZ017StagingMasterBackupsKbbVehicle.safe',
@server = 'p02w02etldzz017',@disconnectusers = 1, @replace = 1
Select @ResultCode as ResultCode
and here is the exception and stack trace that was give:
SQLsafe Backup and Recovery CLI Version 8.0.0.423 (x64) 13:37:14Info Copyright (c) 2004-2014 Idera, Inc., All Rights Reserved. 13:37:14Info http://www.idera.com/ 13:37:14Info Connecting to service on P02W02ETLDZZ017...success. (8.0.0.423) 13:37:14Info RESTORE KbbVehicle...FAILED. 13:37:14Info Server instance: P02W02ETLDZZ017, Database: KBBVehicle 13:37:14Info Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
13:37:14Info
--- End of SQLsafeCmd output ---
13:37:14Info
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
13:37:14Info
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
13:37:14Info
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
13:37:14Info
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
13:37:14Info
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource
1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
13:37:14Info
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
13:37:14Info
at Submission#0..ctor(Session session, Object& submissionResult)
Here is c# code(this is a snipet, this was actually running on octopus tenticle, but tried on visual studio.. same error):
using System.Data.SqlClient;
using System.Data.Common;
using System.Data;
String query = Octopus.Parameters["Octopus.Action[Create RESTORE T-SQL statement based on the given variable(s)].Output.MySqlTextMaster"];
String TargetServer = Octopus.Parameters["Octopus.Action[Constructs the target TargetServer and TargetDatabase variables].Output.TargetServer"];
String TargetDatabase = Octopus.Parameters["Octopus.Action[Constructs the target TargetServer and TargetDatabase variables].Output.TargetDatabase"];
StringBuilder connectionString = new StringBuilder();
connectionString.Append("Server=").Append(TargetServer).Append(";")
.Append("Database=").Append(TargetDatabase).Append(";")
.Append("Trusted_Connection=True;connection timeout= 1200;");
Console.WriteLine(connectionString.ToString());
try
{
using (SqlConnection connection = new SqlConnection(connectionString.ToString()))
{
SqlCommand command = new SqlCommand(query, connection);
command.CommandTimeout = 3600;
//command.CommandType = CommandType.StoredProcedure;
connection.Open();
connection.InfoMessage += (object obj, SqlInfoMessageEventArgs e) => {
System.Console.WriteLine(e.Message);
};
command.ExecuteNonQuery();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
Aucun commentaire:
Enregistrer un commentaire