Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 24th, 2007, 06:53 AM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How i can Backup and Restore Sql Server Database

Backup and Restore Sql Server Database With Asp.net
  #2 (permalink)  
Old April 24th, 2007, 07:03 AM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
i Wrote Following Command In cs File (page.aspx.cs):

SqlConnection.ClearAllPools();
SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=master;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandTimeout = 60;
//try
//{
cmd.CommandText = "use master";
cmd.ExecuteNonQuery();
cmd.CommandText = "ALTER DATABASE Hajir_DB SET SINGLE_USER";
cmd.ExecuteNonQuery();
cmd.CommandText = "Restore Database Hajir_DB From Disk='~\\BackUp\\" + ((String).CommandArgument) + ".dat'";
cmd.ExecuteNonQuery();
cmd.CommandText = "ALTER DATABASE Hajir_DB SET MULTI_USER";
cmd.ExecuteNonQuery();

But This Code Throw Exception:

Cannot Open Backup Device ( File-Path )

and Restore Not Complete.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup and Restore Oracle Database ashu_from_india Oracle 3 October 14th, 2014 12:08 AM
restore thePhile database with 2005 SQL Server ecarnews BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 4 July 2nd, 2007 12:58 PM
How to Backup database - SQL Server 2000 cancer10 SQL Language 2 March 1st, 2007 07:21 AM
How to backup and restore Database phubinh Pro VB Databases 1 June 4th, 2004 03:10 AM
SQL Server Backup Restore zaeem Classic ASP Databases 0 December 4th, 2003 09:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.