Go Back   Talk Root - PC Hardware, Software and Web Development forums > System Administration > Database Servers > SQL Server > SQL Server 2



Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
  #1  
Old 03-23-2004, 01:38 PM
SStory
Guest
 
Posts: n/a
Default Backup/Restore question

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


Reply With Quote
  #2  
Old 03-23-2004, 01:44 PM
Tibor Karaszi
Guest
 
Posts: n/a
Default Re: Backup/Restore question

> 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
>
>



Reply With Quote
  #3  
Old 03-23-2004, 02:08 PM
SStory
Guest
 
Posts: n/a
Default Re: Backup/Restore question

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
> >
> >

>
>



Reply With Quote
  #4  
Old 03-23-2004, 02:29 PM
SStory
Guest
 
Posts: n/a
Default Re: Backup/Restore question

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
> >
> >

>
>



Reply With Quote
  #5  
Old 03-23-2004, 03:22 PM
Tibor Karaszi
Guest
 
Posts: n/a
Default Re: Backup/Restore question

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
> > >
> > >

> >
> >

>
>



Reply With Quote
  #6  
Old 03-23-2004, 03:54 PM
SStory
Guest
 
Posts: n/a
Default Re: Backup/Restore question

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
> > > >
> > > >
> > >
> > >

> >
> >

>
>



Reply With Quote
Reply

Bookmarks
Sponsored Links
FatCow $88 Plan for $66 only Host Unlimited Domains on 1 Account Professional Hosting from Just Host


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On


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


All times are GMT -7. The time now is 10:43 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
© 2008 TalkRoot.com