This is a migrated thread and some comments may be shown as answers.

No connection with the diagram after restoration ?

4 Answers 57 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Richard
Top achievements
Rank 1
Richard asked on 22 Sep 2011, 01:28 PM
Hi,

I made a database restoration, and after the restoration (without quit the application) when I want to access to my database (SQL 2008 R2),
I have this error :
"A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - There is no process at the other end of the channel.)"
  StackTrace "   at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)\r\n   at Telerik.OpenAccess.RT.ExceptionWrapper.Throw()\r\n   at OpenAccessRuntime.storagemanager.logging.LoggingStorageManager.fetchNextQueryResult(ApplicationContext context, RunningQuery runningQuery, Int32 skipAmount)\r\n   at OpenAccessRuntime.DataObjects.SynchronizedPMProxy.getNextQueryResult(QueryResultWrapper aQrs, Int32 skipAmount)\r\n   at OpenAccessRuntime.DataObjects.ForwardQueryResult.Initialize(Int32 indexParam)\r\n   at OpenAccessRuntime.DataObjects.ForwardQueryResult.get_Item(Int32 indexParam)\r\n   at OpenAccessRuntime.DataObjects.SynchronizedQueryResult.get_Item(Int32 index)\r\n   at Telerik.OpenAccess.RT.ListEnumerator.setCurrent(Int32 _pos)\r\n   at Telerik.OpenAccess.RT.ListEnumerator.Move(Int32 relative)\r\n   at Telerik.OpenAccess.RT.ListEnumerator.MoveNext()\r\n   at Telerik.OpenAccess.Query.TypedEnumerator`1.System.Collections.IEnumerator.MoveNext()\r\n   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n   at PHS.DataAccess.Data_TestRequest.GetAllTestRequests() in C:\\Appli\\Stago\\PHS\\Functional_Model\\GUI\\Dev\\v1\\PHS\\DataAccess\\Data_TestRequest.cs:line 134\r\n   at PHS.BusinessServices.BS_TestRequest.RemoveExpiredResults() in C:\\Appli\\Stago\\PHS\\Functional_Model\\GUI\\Dev\\v1\\PHS\\BusinessServices\\BS_TestRequest.cs:line 370" string


How can I do, please ?
In advance,
Thanks.

4 Answers, 1 is accepted

Sort by
0
Ivailo
Telerik team
answered on 27 Sep 2011, 10:22 AM
Hi Richard,

Can you verify that:
1. The database is up
2. You are able to access the database with another tool

Is it possible to check whether after restarting your application, the exception is still thrown? Also, in case the database is used through a web service, you can try to refresh it through restarting the IIS application pool of the web service.

I am looking forward to your feedback.


All the best,
Ivailo
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

0
Richard
Top achievements
Rank 1
answered on 27 Sep 2011, 11:26 AM
Hi,
I made my database restoration in my application (is it a winform application).

And when I made my databse restoration (with Microsoft method "SMO"), the restoration works normly, but when I want to access to an element in my database with my diagram (telerik diagram), I have the error message...
See below code used for the database restoration:

I think that the SQL database service or the database diagram is stopped ????
How can "restart" the connection with my "new databse" ?

NB:
When I restart my application, the connection with the database is OK, I can access to element in my database !

In advance,
Thanks.

public bool Restore_Database(string cs_SQL, string cs_Login, string cs_Password, string cs_DataBaseName, string cs_FullPath)

{

 

bool b_Ret = true;

 

Server dbServer = new Server(new ServerConnection(cs_SQL, cs_Login, cs_Password));

 

Restore dbRestore = new Restore();

dbRestore.Database = cs_DataBaseName;

dbRestore.Action =

 

RestoreActionType.Database;

 

/* Keep in mind that the file path you use here is relative to the SQL Server, not your local file system */

dbRestore.Devices.AddDevice(cs_FullPath,

 

DeviceType.File);

 

/* Leaving the ReplaceDatabase value set to the default of false will not create

* a new database image so the database that is set must exist on the SQL server

* If you change the Incremental value to true it will create a new image of the

* database regardless of whether it currently exists or not

*/

dbRestore.ReplaceDatabase =

 

true;

 

/* Leaving the NoRecovery value set to the default of false the tail end of the log

* is backed up and the database will not be in a Restoring state

* If you change the NoRecovery value to true then the database will be left in a

* Restoring state.

* This option is only used when the log is backed up as well

*/

 

//dbRestore.NoRecovery = false;

 

 

/* There are several events that you can wire up to the Restore object

* These will allow you to keep track of:

* The current progress of the restore

* When the current backup media is exhausted (next disk)

* When the current backup is completed

* When a message not captured by the above options is sent

*/

dbRestore.PercentComplete +=

 

new PercentCompleteEventHandler(dbRestore_PercentComplete);

dbRestore.Complete +=

 

new ServerMessageEventHandler(dbRestore_Complete);

dbRestore.NextMedia +=

 

new ServerMessageEventHandler(dbRestore_NextMedia);

dbRestore.Information +=

 

new ServerMessageEventHandler(dbRestore_Information);

 

/* You can also use SqlRestoreAsync with the same parameter if you want to run

* asynchronously

*

***************************** IMPORTANT NOTE ********************************

* In order to perform a restore you must be able to acquire an exclusive lock

* on the database or it will fail

*

* You can easily check to see what processes are currently running on the

* database with the following command (alternatively you can use SP_WHO)

*

* SELECT spid

* FROM master..SysProcesses

* WHERE DBID IN (SELECT dbid FROM master..SysDatabases WHERE name = 'EPSS_PRD_EN')

*

* Once you have the list of the running processes against the DB you can use the

* KILL procedure to terminate the session in order to free up the DB for restore

*/

 

try

{

 

//SqlConnection oSqlConnection = new SqlConnection(@"data source=localhost\SQL;initial catalog=PHS_DataBase;user id=sa;password=pwd");

 

//oSqlConnection.Open();

 

//string cs_Command = "SELECT spid FROM master..SysProcesses WHERE DBID IN (SELECT dbid FROM master..SysDatabases WHERE name = 'EPSS_PRD_EN')";

 

//string cs_Command = "Alter database PHS_DataBase set single_User with ROLLBACK IMMEDIATE";

 

//SqlCommand oSqlCommand = new SqlCommand(cs_Command, oSqlConnection);

 

 

//string returnvalue = (string)oSqlCommand.ExecuteScalar();

dbRestore.RestrictedUser =

 

true;

 

//dbServer.KillAllProcesses(cs_DataBaseName);

 

//dbRestore.ReplaceDatabase = true;

 

Database SmoDatabase = dbServer.Databases[cs_DataBaseName];

 

if (SmoDatabase.UserAccess != DatabaseUserAccess.Single)

{

SmoDatabase.UserAccess =

 

DatabaseUserAccess.Single;

SmoDatabase.Alter(

 

TerminationClause.RollbackTransactionsImmediately);

SmoDatabase.Refresh();

}

dbRestore.SqlRestore(dbServer);

SmoDatabase.UserAccess =

 

DatabaseUserAccess.Multiple;

SmoDatabase.Alter(

 

TerminationClause.RollbackTransactionsImmediately);

SmoDatabase.Refresh();

}

 

catch (Exception err)

{

b_Ret =

 

false;

 

if (Event_Restore_Failed != null)

Event_Restore_Failed();

}

 

return b_Ret;

}



0
Ivailo
Telerik team
answered on 30 Sep 2011, 08:05 AM
Hi Richard,

Now I understood what you are trying to achieve. It is possible, however you need to do one thing - dispose your database connection and re-instantiate your Domain Model, like in the following example:

EntitiesModel model = new EntitiesModel();
 
var customerId1 = model.Customers.FirstOrDefault().ID;
 
Database.Get("ConnectionStringName").Dispose();
 
model = new EntitiesModel();
 
var customerId2 = model.Customers.FirstOrDefault().ID;

For ConnectionStringName you can use the name of the connection string as defined in your configuration files. I hope this approach will fix your database access problem after the restoration.

I am looking forward to your feedback.


Best wishes,
Ivailo
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

0
Richard
Top achievements
Rank 1
answered on 30 Sep 2011, 09:24 AM
Hi,

Thanks for your reply.
Tags
Development (API, general questions)
Asked by
Richard
Top achievements
Rank 1
Answers by
Ivailo
Telerik team
Richard
Top achievements
Rank 1
Share this question
or