dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online Membersnaveensanagasetti
Kalandiyur Subramanian
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

Database Backup usingc#.net


Posted Date: 05 Aug 2010      Posted By:: saravanan     Member Level: Silver    Member Rank: 1751     Points: 1   Responses: 3



Hi dear friends,

I m developing an application using C#.Net 2005 and MySql 5.0

How to take backup of specific database in MySql 5.0 and Restore the backup database through C#.net 2.0???Can u give me the entire code for this one...i need the aspx.cs ,aspx and where i have to write the codes.....plz dears...its very urgent.............




Responses

#535132    Author: Christopher F      Member Level: Gold      Member Rank: 172     Date: 05/Aug/2010   Rating: 2 out of 52 out of 5     Points: 2

Please refer this link


http://www.codeproject.com/KB/database/SQL_Server_2005_Database.aspx

http://www.codersource.net/asp-net/ado-net/sql-dmo-for-automated-database-backup-and-restore.aspx



 
#535149    Author: VASANTH R      Member Level: Gold      Member Rank: 311     Date: 05/Aug/2010   Rating: 2 out of 52 out of 5     Points: 2

String ServerName="WEBMS";
String DBName"E123";
String UserName="sa";
BackupDeviceItem bdi = new BackupDeviceItem(BackupPath, DeviceType.File);
Microsoft.SqlServer.Management.Smo.Backup bu = new Microsoft.SqlServer.Management.Smo.Backup();
bu.Database = DBName;
bu.PercentComplete +=new PercentCompleteEventHandler(bu_PercentComplete);
bu.Devices.Add(bdi);
bu.Initialize = true;
Server server = new Server(ServerName);
bu.SqlBackup(server);

Regards,
R.Vasanth



 
#535168    Author: vasanth      Member Level: Silver      Member Rank: 889     Date: 05/Aug/2010   Rating: 2 out of 52 out of 5     Points: 2

public void BackupDatabase(String databaseName, String userName,
String password, String serverName, String destinationPath)
{
Backup sqlBackup = new Backup();

sqlBackup.Action = BackupActionType.Database;
sqlBackup.BackupSetDescription = "ArchiveDataBase:" +
DateTime.Now.ToShortDateString();
sqlBackup.BackupSetName = "Archive";

sqlBackup.Database = databaseName;

BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File);
ServerConnection connection = new ServerConnection(serverName, userName, password);
Server sqlServer = new Server(connection);

Database db = sqlServer.Databases[databaseName];

sqlBackup.Initialize = true;
sqlBackup.Checksum = true;
sqlBackup.ContinueAfterError = true;

sqlBackup.Devices.Add(deviceItem);
sqlBackup.Incremental = false;

sqlBackup.ExpirationDate = DateTime.Now.AddDays(3);
sqlBackup.LogTruncation = BackupTruncateLogType.Truncate;

sqlBackup.FormatMedia = false;

sqlBackup.SqlBackup(sqlServer);
}






 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Tree view
Previous : Bulk insert in sqlserver
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.