Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transport-Level Error after restoring a DB

Status
Not open for further replies.

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;
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?
 
Just a shot in the dark here, but could it be that your DAL instance is trying to use a connection to the pre-restore database?

[small]----signature below----[/small]
Majority rule don't work in mental institutions

My Crummy Web Page
 
I'll have to look into it, this is tabled for now, but I will end up coming back to it soon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top