dseaver
IS-IT--Management
- Jul 13, 2006
- 467
I get this message when I restore a DB then try to create objects that pertain to that DB;
I use this code to restore the DB
When I create new BLLs that interact with the DB (using our api, DAL + BLL format), as soon as I run a query, the error is thrown. If I skip over the query itself and initialize the BLLs a second time, the query will execute. I have tried delaying the thread 10 seconds and double initializing the BLLs, and I still get the error.
Any Ideas?
Code:
Error:
A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)
I use this code to restore the DB
Code:
//try
//{
_SQLServer srv = new SQLDMO.SQLServerClass();
//connect to the server
srv.LoginSecure = true;
srv.Connect("(local)\\SQLEXPRESS", null, null);
SQLDMO.Database test = (SQLDMO.Database)srv.Databases.Item("Master", null);
string CommandText = "use Master; Alter Database Database SET SINGLE_USER With ROLLBACK IMMEDIATE";
test.ExecuteImmediate(CommandText, SQLDMO_EXEC_TYPE.SQLDMOExec_Default, CommandText.Length);
//create a restore class instance
Restore res = new SQLDMO.RestoreClass();
//set the backup device = files property ( easy way )
res.Devices = res.Files;
//set the files property to the File Name text box
res.Files = @"c:\Database.bak";
//set the database to the chosen database
res.Database = "Database";
// Restore the database
res.ReplaceDatabase = true;
res.SQLRestore(srv);
CommandText = "use Master; Alter Database Database SET MULTI_USER";
test.ExecuteImmediate(CommandText, SQLDMO_EXEC_TYPE.SQLDMOExec_Default, CommandText.Length);
srv.DisConnect();
MessageBox.Show("Database restored successfully.", "Restore Successful");
When I create new BLLs that interact with the DB (using our api, DAL + BLL format), as soon as I run a query, the error is thrown. If I skip over the query itself and initialize the BLLs a second time, the query will execute. I have tried delaying the thread 10 seconds and double initializing the BLLs, and I still get the error.
Any Ideas?