Re: Backup/Restore question
From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 03/23/04
- Next message: Aaron Bertrand [MVP]: "Re: accessing sysobjects is good or bad if not wat is the solution"
- Previous message: Erland Sommarskog: "Re: Newbie needs help with BCP out file"
- In reply to: SStory: "Re: Backup/Restore question"
- Next in thread: SStory: "Re: Backup/Restore question"
- Reply: SStory: "Re: Backup/Restore question"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Mar 2004 00:22:07 +0100
You can use the ExecuteNonQuery method, for instance. If it fails, you
should get an exception in your client code which you can capture with
standard .NET error handling (TRY and CATCH).
-- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp "SStory" <TheStorys@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message news:%23nhDTYSEEHA.3672@TK2MSFTNGP09.phx.gbl... > One more question then. > In ADO.NET > > I pass the backup statement. > How can I tell if it failed or not. > > In a Stored proc I would check @ERROR or @@ERRor (can't remember which) > > So howto? > > Thanks, > > Shane > "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in > message news:O7Ai9$REEHA.3372@TK2MSFTNGP10.phx.gbl... > > > I would need to either somehow connect and install a blank copy of the > > > database and then restore from the backup file??? > > > > No need to create a "blank database" first. The database is created for > you > > when you execute the RESTORE command. > > > > > > > Now how do I connect to the server to do this if the database isn't > > > there--via ADO.NET conn string? > > > > As for your connection from ADO, just connect to the master database and > > execute your restore command from there. > > > > > > > also am I correct that a restore will wipe-out/replace the existing > > database > > > with the backed up one? > > > > Yes, assuming the existing one has the same layout for the database files. > > If not, then you'll get an error message. You can either delete the > database > > first and then do the restore or use the REPLACE parameter to the restore > > command (same thing). > > -- > > Tibor Karaszi, SQL Server MVP > > http://www.karaszi.com/sqlserver/default.asp > > > > > > "SStory" <TheStorys@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message > > news:%23dB$q7REEHA.712@tk2msftngp13.phx.gbl... > > > I want to offer a simple backup/restore option in my vb.net app. > > > > > > So I did BACKUP DATABASE MYDB TO DISK="D:\SOMEFILENAME.BKP > > > > > > I execute this via a SQLCommand object. > > > > > > backup is simple. But say the database gets wiped out, then they > > reinstall > > > MSDE. > > > > > > I would need to either somehow connect and install a blank copy of the > > > database and then restore from the backup file??? > > > > > > Now how do I connect to the server to do this if the database isn't > > > there--via ADO.NET conn string? > > > > > > Am I missing something? > > > > > > also am I correct that a restore will wipe-out/replace the existing > > database > > > with the backed up one? > > > > > > Thanks > > > > > > Shane > > > > > > > > > > > >
- Next message: Aaron Bertrand [MVP]: "Re: accessing sysobjects is good or bad if not wat is the solution"
- Previous message: Erland Sommarskog: "Re: Newbie needs help with BCP out file"
- In reply to: SStory: "Re: Backup/Restore question"
- Next in thread: SStory: "Re: Backup/Restore question"
- Reply: SStory: "Re: Backup/Restore question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|