5 Replies - 2255 Views - Last Post: 08 May 2013 - 10:56 AM Rate Topic: -----

#1 Bladewing51  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 76
  • Joined: 26-August 11

Programatically back-up and restore a MSSQL DB

Posted 08 May 2013 - 10:17 AM

Back with another question, my app uses an SQL express server to store a database, in an effort to minimize the users ability to "Screw themselves" I do not want to include SQL server management studio with my app.

My issue is I would still like to include a way for the user to back-up or restore a database to the SQL Server so I'm attempting to create code where this can be done from the app itself.

My question is how can this be accomplished?

I suspect I could possibly use an SQLCommand or parameter but the only ones I know have to do with tables, I have little experience interacting with the database itself via commands. Is it possible to do this via a stored procedure that I can call from my app?

I have seen this done before creating a .bck file, annoyingly I cant find anything about this that doesn't use SMO's from the SSMS.

Any help would be appreciated, I would include code but I currently only have the connection string and interface with no real "MEAT" in it.

Is This A Good Question/Topic? 0
  • +

Replies To: Programatically back-up and restore a MSSQL DB

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9056
  • View blog
  • Posts: 33,998
  • Joined: 12-June 08

Re: Programatically back-up and restore a MSSQL DB

Posted 08 May 2013 - 10:25 AM

You know.. you could totally just write out the table data into a CSV and have a quick and dirty backup!
Was This Post Helpful? 0
  • +
  • -

#3 Bladewing51  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 76
  • Joined: 26-August 11

Re: Programatically back-up and restore a MSSQL DB

Posted 08 May 2013 - 10:36 AM

That's a possibility...But that introduces a chance that the user tries to open that .csv in excel which auto formats the columns and rows adding 0's and letters where they don't belong. :/
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9056
  • View blog
  • Posts: 33,998
  • Joined: 12-June 08

Re: Programatically back-up and restore a MSSQL DB

Posted 08 May 2013 - 10:46 AM

Don't save it as a CSV extension.. slap some new extension on it.. like ".666"!
Was This Post Helpful? 0
  • +
  • -

#5 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Programatically back-up and restore a MSSQL DB

Posted 08 May 2013 - 10:46 AM

http://expressmaint.codeplex.com/

I use this but I put it in the task scheduler to perform daily

You could probably spawn a process when the user clicks the backup button.

At the very least, the author gives access to the source code where you can probably learn how to perform your own backup.
Was This Post Helpful? 0
  • +
  • -

#6 Aboch  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 50
  • Joined: 28-April 09

Re: Programatically back-up and restore a MSSQL DB

Posted 08 May 2013 - 10:56 AM

Maybe this? http://www.mindfires...n-VBNET-846.php and
http://msdn.microsof...y/ms162169.aspx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1