|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
> 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 [url]http://www.karaszi.com/sqlserver/default.asp[/url] "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 > > |
|
#3
|
|||
|
|||
|
I thought I might have to connect to master for that.
thanks. Shane "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.co m> 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 > [url]http://www.karaszi.com/sqlserver/default.asp[/url] > > > "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 > > > > > > |
|
#4
|
|||
|
|||
|
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.co m> 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 > [url]http://www.karaszi.com/sqlserver/default.asp[/url] > > > "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 > > > > > > |
|
#5
|
|||
|
|||
|
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 [url]http://www.karaszi.com/sqlserver/default.asp[/url] "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.co m> 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 > > [url]http://www.karaszi.com/sqlserver/default.asp[/url] > > > > > > "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 > > > > > > > > > > > > |
|
#6
|
|||
|
|||
|
Thanks,
I will try to get this going. Shane "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.co m> wrote in message news:%23CrIq2SEEHA.2600@TK2MSFTNGP09.phx.gbl... > 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 > [url]http://www.karaszi.com/sqlserver/default.asp[/url] > > > "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.co m> 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 > > > [url]http://www.karaszi.com/sqlserver/default.asp[/url] > > > > > > > > > "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 > > > > > > > > > > > > > > > > > > > > |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Java question | op4545 | Everything Else | 0 | 07-17-2008 05:45 AM |
| Proverbial Computer Question | Mirey86 | Hardware | 0 | 05-20-2008 04:22 AM |